#No Output Directory named "public" found after the Build completed. You can configure the Output Dir

1 messages · Page 1 of 1 (latest)

subtle estuary
#

turbo.json:
{
"$schema": "https://turbo.build/schema.json",
"ui": "tui",
"tasks": {
"build": {
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": [".next/", "!.next/cache/"]
},
"lint": {
"dependsOn": ["^lint"]
},
"check-types": {
"dependsOn": ["^check-types"]
},
"dev": {
"cache": false,
"persistent": true
}
}
}

apps/web package.json:
{
"name": "web",
"version": "0.0.1",
"type": "module",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@workspace/ui": "workspace:",
"better-auth": "^1.1.18",
"lucide-react": "0.456.0",
"next": "^15.1.0",
"next-themes": "^0.4.3",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "18.3.0",
"@types/react-dom": "18.3.1",
"@workspace/eslint-config": "workspace:^",
"@workspace/typescript-config": "workspace:
",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
}

monorepo package.json:
{
"name": "simplist",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"format": "prettier --write "**/.{ts,tsx,md}""
},
"devDependencies": {
"@workspace/eslint-config": "workspace:
",
"@workspace/typescript-config": "workspace:*",
"prettier": "^3.2.5",
"turbo": "^2.3.0",
"typescript": "5.5.4"
},
"packageManager": "pnpm@9.12.3",
"engines": {
"node": ">=20"
}
}

pearl streamBOT
#

Hi @subtle estuary. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in your question and the knowledge sources, it appears that you're encountering an issue with your Turborepo configuration in a Next.js project. The error message suggests that the "public" directory is not being found after the build process. Let's address this issue:

  1. First, it's important to note that the public directory is used by Next.js for static assets. According to the Next.js documentation on static assets, the public directory is used to serve static files from the base URL (/).

  2. In your turbo.json configuration, you're currently specifying the outputs as:

    "outputs": [".next/**", "!.next/cache/**"]
    

    This configuration is correct for caching the Next.js build output, but it doesn't include the public directory.

  3. To resolve this issue, you should add the public directory to your outputs in the turbo.json file. Here's how you can modify your build task:

    "build": {
      "dependsOn": ["^build"],
      "inputs": ["$TURBO_DEFAULT$", ".env*"],
      "outputs": [".next/**", "!.next/cache/**", "public/**"]
    }
    
  4. Additionally, make sure that you have a public directory in your Next.js project (in this case, in the apps/web directory). If it doesn't exist, create one.

  5. It's also worth noting that according to the Vercel documentation on Turborepo troubleshooting, unexpected cache misses can occur. If you're deploying to Vercel, you might want to check the Turborepo Run Summary for your deployment to see if there are any cache-related issues.

#
  1. Lastly, ensure that your Next.js configuration (usually in next.config.js) doesn't have any custom distDir setting that might be affecting the location of your build output.

By making these changes, you should be able to resolve the "No Output Directory named 'public' found" error. If the issue persists, you may need to investigate further into your project structure and build process.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@subtle estuary Kapa.ai is still learning and improving, please let me know how I did by reacting below.

subtle estuary
#

@pearl stream now i have Error: No Next.js version could be detected in your project. Make sure "next" is installed in "dependencies" or "devDependencies"

pearl streamBOT
#

Let me check the knowledge base for you again. Give me one moment! :books:

#

Based on the information provided in your question and the knowledge sources, it appears you're encountering a new error related to the Next.js package not being detected in your project. Let's address this issue:

  1. First, it's important to note that the error message suggests that the "next" package is not properly installed or detected in your project's dependencies.

  2. Looking at your apps/web/package.json file, I can see that you have Next.js installed as a dependency:

    "dependencies": {
      "next": "^15.1.0",
      ...
    }
    

    This is the correct way to include Next.js in your project.

  3. However, there could be several reasons why the Next.js package is not being detected:

    a. The package might not be properly installed. Try running the install command again in your project root:

    pnpm install
    

    b. There might be an issue with your monorepo setup or workspace configuration.

  4. According to the Github issue about Next.js package not being found, some users have reported similar issues when using pnpm in a monorepo setup. One solution that worked for some users was to delete the node_modules folder and the lock file, then reinstall the dependencies:

    rm -rf node_modules pnpm-lock.yaml
    pnpm install
    
  5. If the issue persists, you might want to try running your Next.js commands with the --prefix flag to ensure you're in the correct directory:

    pnpm --prefix apps/web dev
    
  6. Another potential solution, as mentioned in the Github issue about Next.js package not being found in a monorepo, is to add the following to your root package.json:

    "packageManager": "pnpm@9.12.3"
    
#

Oh, I see you already have this in your monorepo package.json, so this isn't the issue.

  1. If none of the above solutions work, you might want to check if there are any conflicts between your global and local Next.js installations. Try using pnpm why next to see where the Next.js package is coming from.

If you continue to face issues after trying these solutions, it might be helpful to provide more information about your project structure and the exact commands you're running when you encounter this error.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@subtle estuary Kapa.ai is still learning and improving, please let me know how I did by reacting below.

subtle estuary
#

@pearl stream

pearl streamBOT
#

Let me check the knowledge base for you again. Give me one moment! :books: