vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.09k stars 27.01k forks source link

Unable to build app in 12.0.1 with concurrentFeatures enabled #30424

Closed Johannes-Andersen closed 3 years ago

Johannes-Andersen commented 3 years ago

What version of Next.js are you using?

Attempted: v12.0., v12.0.2-canary.2 and v12.0.2-canary.11

What version of Node.js are you using?

Attempted: node/14.18.1 and node/16.13.0

What browser are you using?

Chrome (N/A)

What operating system are you using?

macOS Monterey

How are you deploying your application?

Vercel

Describe the Bug

When updating from v12.0.0 to v12.0.1 it broke next build and next dev’. next lint` still works

Looking into the canary versioned packages: "12.0.1-canary.0" - WORKS "v12.0.1-canary.1" - DOES NOT WORK

So it could possibly be: #30299

next build output:

> next build

warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

warn  - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled
info  - Checking validity of types  
info  - Using the createRoot API for React
warn  - You are using an unsupported prerelease of 'react-dom' which may cause unexpected or broken application behavior. Continue at your own risk.
info  - Using the experimental web runtime.
info  - You have experimental React Server Components enabled.
info  - Creating an optimized production build  
Failed to compile.

./node_modules/next-i18next/dist/commonjs/serverSideTranslations.js
Module not found: Can't resolve 'fs' in '/Users/johannesandersen/Desktop/Johand/node_modules/next-i18next/dist/commonjs'

Import trace for requested module:
./node_modules/next-i18next/serverSideTranslations.js
./src/pages/404.tsx
./node_modules/next/dist/build/webpack/loaders/next-middleware-ssr-loader/index.js?page=%2F404&absolutePagePath=private-next-pages%2F404.tsx&isServerComponent=false&buildId=ciWvOQ9-dlRLa2Xan2Fte&basePath=&assetPrefix=!

./node_modules/next/dist/build/webpack/loaders/next-middleware-ssr-loader/index.js?page=%2F&absolutePagePath=private-next-pages%2Findex.tsx&isServerComponent=false&buildId=ciWvOQ9-dlRLa2Xan2Fte&basePath=&assetPrefix=!
Module not found: Can't resolve '/Users/johannesandersen/Desktop/Johand/pages/_document' in '/Users/johannesandersen/Desktop/Johand'

./node_modules/next/dist/build/webpack/loaders/next-middleware-ssr-loader/index.js?page=%2F&absolutePagePath=private-next-pages%2Findex.tsx&isServerComponent=false&buildId=ciWvOQ9-dlRLa2Xan2Fte&basePath=&assetPrefix=!
Module not found: Can't resolve '/Users/johannesandersen/Desktop/Johand/pages/_app' in '/Users/johannesandersen/Desktop/Johand'

./node_modules/next/dist/build/webpack/loaders/next-middleware-ssr-loader/index.js?page=%2F404&absolutePagePath=private-next-pages%2F404.tsx&isServerComponent=false&buildId=ciWvOQ9-dlRLa2Xan2Fte&basePath=&assetPrefix=!
Module not found: Can't resolve '/Users/johannesandersen/Desktop/Johand/pages/_document' in '/Users/johannesandersen/Desktop/Johand'

./node_modules/next/dist/build/webpack/loaders/next-middleware-ssr-loader/index.js?page=%2F404&absolutePagePath=private-next-pages%2F404.tsx&isServerComponent=false&buildId=ciWvOQ9-dlRLa2Xan2Fte&basePath=&assetPrefix=!
Module not found: Can't resolve '/Users/johannesandersen/Desktop/Johand/pages/_app' in '/Users/johannesandersen/Desktop/Johand'

> webpack config.resolve.alias was incorrectly overridden. https://nextjs.org/docs/messages/invalid-resolve-alias

Nex dev output:

> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

warn  - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled
info  - Using the createRoot API for React
warn  - You are using an unsupported prerelease of 'react-dom' which may cause unexpected or broken application behavior. Continue at your own risk.
info  - Using the experimental web runtime.
info  - You have experimental React Server Components enabled.
wait  - compiling...
event - compiled successfully in 5s (225 modules)
warn  - using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware
wait  - compiling /...
wait  - compiling...
error - ./node_modules/next-i18next/dist/commonjs/serverSideTranslations.js
Module not found: Can't resolve 'fs' in '/Users/johannesandersen/Desktop/Johand/node_modules/next-i18next/dist/commonjs'
error - Error: ENOENT: no such file or directory, open '/Users/johannesandersen/Desktop/Johand/.next/server/middleware-ssr-runtime.js'
wait  - compiling /_error...
wait  - compiling...
error - ./node_modules/next-i18next/dist/commonjs/serverSideTranslations.js
Module not found: Can't resolve 'fs' in '/Users/johannesandersen/Desktop/Johand/node_modules/next-i18next/dist/commonjs'

Expected Behavior

When running npm run build it should creating an optimized production build

To Reproduce

  1. Pull this branch down: https://github.com/Johannes-Andersen/Johand/tree/next12.0.1
  2. npm install 3, and then try and build the app

Screenshot 2021-10-27 at 12 07 00

FrontLeejonghun commented 3 years ago

same having error to me *projectFolder = in pubilc project folder

What version of Next.js are you using? v12.0.1

What version of Node.js are you using? Attempted: node/14.18.1

What browser are you using? Chrome (N/A)

What operating system are you using? macOS catalina / window 10

pack

    "next": "^12.0.1",
    "react": "^18.0.0-alpha-4298ddbc5-20211023",
    "react-dom": "^18.0.0-alpha-4298ddbc5-20211023",

next.config

  experimental: {
    concurrentFeatures: true,
    serverComponents: true,
  },
  swcMinify: true

tsconfig

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "baseUrl": "./src",
    "types": [
      "jest"
    ],
    "incremental": true
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}

error - Error: ENOENT: no such file or directory, open 'projectFolder.next\server\middleware-ssr-runtime.js' Module not found: Can't resolve 'projectFolder/pages/_document' in 'projectFolder'

who have this erorr same as us ....!?

Johannes-Andersen commented 3 years ago

Clicked the wrong button, reopened

It could just have been next-i18next that needs to add support

FrontLeejonghun commented 3 years ago

@Johannes-Andersen If i can found solution i will coment here :(

starburst997 commented 3 years ago

Similar issue for me as well, v12.0.0 works, v12.0.1 unable to build / run, log is different but might have the same root issue.

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /404
    at pageNotFoundError (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/server/load-components.js:58:23)
    at /home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/trace/trace.js:74:20)
info  - Generating static pages (1/1)

> Build error occurred
Error: Export encountered errors on following paths:
        /404
    at /home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/export/index.js:493:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/trace/trace.js:74:20)
    at async /home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/build/index.js:956:17
    at async Span.traceAsyncFn (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/trace/trace.js:74:20)
    at async /home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/build/index.js:830:13
    at async Span.traceAsyncFn (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/trace/trace.js:74:20)
    at async Object.build [as default] (/home/starburst/notessimo-web/notessimo-web/node_modules/next/dist/build/index.js:80:25)
bbigras commented 3 years ago

I got this problem with a fresh project and this next.config.js:

module.exports = {
  reactStrictMode: true,
  experimental: {
    concurrentFeatures: true,
    serverComponents: true
  }
}
starburst997 commented 3 years ago

Seems like concurrentFeatures: true is the issue and is broken in v12.0.1, turning it off fix it for me.

vvenv commented 3 years ago

just trying resolve fallback:

{
  webpack: (config) => {
    config.resolve.fallback = { fs: false };

    return config;
  },
}
nicosh commented 3 years ago

Edit My bad, on the server was running a not supported version of Node (10) while next 12 needs Node.js 12.22.0 or later

Similar issue for me with next.js 12.0.1, i can build the app on my local machine (windows 10) but it fails on the server ( ubuntu 20.04) For every page i get this error :

Error [ERR_METHOD_NOT_IMPLEMENTED]: The _write() method is not implemented
    at Writable._write (_stream_writable.js:566:6)
    at doWrite (_stream_writable.js:415:12)
    at clearBuffer (_stream_writable.js:545:7)
    at Writable.uncork (_stream_writable.js:319:7)
shuding commented 3 years ago

Update: #30642 resolves the "Module not found: Can't resolve 'projectFolder/pages/_document'" issue.

shuding commented 3 years ago

For the "Cannot resolve fs" error, since concurrentFeatures enables the Edge Runtime, there will be some constraints applied. For example Native Node.js APIs are not supported. We will make sure to improve the error message here.

Related docs: https://nextjs.org/docs/advanced-features/react-18#enable-ssr-streaming-alpha and https://nextjs.org/docs/api-reference/edge-runtime#unsupported-apis.

Johannes-Andersen commented 3 years ago

Closing based on comment from shuding above.

The errors I had above is gone when I removed the fs dependency and upgraded to 12.0.2-canary.13 to remove the "Module not found: Can't resolve 'projectFolder/pages/_document'" issue.

Just noting, I am now seeing a new issue when concurrentFeatures is true:

johannesandersen@Bel-MBP-JAndersen Johand % npm run build && npm start

> johand@0.0.1 build
> next build

warn  - You have enabled experimental feature(s).
warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.

warn  - SWC minify beta enabled. https://nextjs.org/docs/messages/swc-minify-enabled
info  - Checking validity of types  
info  - Using the createRoot API for React
warn  - You are using an unsupported prerelease of 'react-dom' which may cause unexpected or broken application behavior. Continue at your own risk.
info  - Using the experimental web runtime.
info  - You have experimental React Server Components enabled.
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data  
[    ] info  - Generating static pages (0/6)
Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /500
    at pageNotFoundError (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/load-components.js:58:23)
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)

Error occurred prerendering page "/en/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /404
    at pageNotFoundError (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/load-components.js:58:23)
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)

Error occurred prerendering page "/en/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /500
    at pageNotFoundError (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/load-components.js:58:23)
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)

Error occurred prerendering page "/nb-NO/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /404
    at pageNotFoundError (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/load-components.js:58:23)
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)

Error occurred prerendering page "/nb-NO/500". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /500
    at pageNotFoundError (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/load-components.js:58:23)
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)

Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
Error: Cannot find module for page: /404
    at pageNotFoundError (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:16:17)
    at getPagePath (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:39:15)
    at Object.requirePage (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/require.js:44:22)
    at Object.loadComponents (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/server/load-components.js:58:23)
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/worker.js:218:63
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)
info  - Generating static pages (6/6)

> Build error occurred
Error: Export encountered errors on following paths:
    /404
    /500
    /en/404
    /en/500
    /nb-NO/404
    /nb-NO/500
    at /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/export/index.js:493:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)
    at async /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/build/index.js:956:17
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)
    at async /Users/johannesandersen/Desktop/Johand/node_modules/next/dist/build/index.js:830:13
    at async Span.traceAsyncFn (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/trace/trace.js:74:20)
    at async Object.build [as default] (/Users/johannesandersen/Desktop/Johand/node_modules/next/dist/build/index.js:80:25)

But that does not seem related to this issue.

balazsorban44 commented 2 years ago

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.