-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nextjs 13.4.9 - Error: Cannot find module 'webpack' #52366
Comments
In production build runs ok, but in dev it throws this error in my pull request with upgrade Dev mode error in console/usr/local/bin/yarn run dev
yarn run v1.22.17
$ next dev
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from /Users/marcus-rise/WebstormProjects/My-Site/.env
- info (pwa) PWA support is disabled.
- info (pwa) PWA support is disabled.
- event compiled client and server successfully in 725 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 87 ms (20 modules)
- wait compiling /page (client and server)...
- event compiled client and server successfully in 898 ms (535 modules)
- error Error: Cannot find module 'webpack'
Require stack:
- /Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/generate-sw.js
- /Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/index.js
- /Users/marcus-rise/WebstormProjects/My-Site/node_modules/@ducanh2912/next-pwa/dist/index.cjs
- /Users/marcus-rise/WebstormProjects/My-Site/next.config.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at /Users/marcus-rise/WebstormProjects/My-Site/node_modules/next/dist/server/require-hook.js:185:36
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (/Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/generate-sw.js:18:35)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12) {
type: 'Error',
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/generate-sw.js',
'/Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/index.js',
'/Users/marcus-rise/WebstormProjects/My-Site/node_modules/@ducanh2912/next-pwa/dist/index.cjs',
'/Users/marcus-rise/WebstormProjects/My-Site/next.config.js'
]
}
- wait compiling /_error (client and server)...
- event compiled client and server successfully in 226 ms (668 modules)
- wait compiling /favicon.ico/route (client and server)...
- event compiled client and server successfully in 136 ms (713 modules)
Error: Cannot find module 'webpack'
Require stack:
- /Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/generate-sw.js
- /Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/index.js
- /Users/marcus-rise/WebstormProjects/My-Site/node_modules/@ducanh2912/next-pwa/dist/index.cjs
- /Users/marcus-rise/WebstormProjects/My-Site/next.config.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
at /Users/marcus-rise/WebstormProjects/My-Site/node_modules/next/dist/server/require-hook.js:185:36
at Module._load (node:internal/modules/cjs/loader:920:27)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object.<anonymous> (/Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/generate-sw.js:18:35)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/generate-sw.js',
'/Users/marcus-rise/WebstormProjects/My-Site/node_modules/workbox-webpack-plugin/build/index.js',
'/Users/marcus-rise/WebstormProjects/My-Site/node_modules/@ducanh2912/next-pwa/dist/index.cjs',
'/Users/marcus-rise/WebstormProjects/My-Site/next.config.js'
]
} Production successfull build logs on Vercel[10:22:15.040] Running build in Cleveland, USA (East) – cle1
[10:22:15.101] Cloning github.com/Marcus-Rise/My-Site (Branch: chore/upgrade, Commit: 71c2b4a)
[10:22:15.500] Cloning completed: 398.989ms
[10:22:18.448] Restored build cache
[10:22:18.479] Running "vercel build"
[10:22:18.981] Vercel CLI 31.0.1
[10:22:19.246] Installing dependencies...
[10:22:19.556] yarn install v1.22.17
[10:22:19.625] [1/4] Resolving packages...
[10:22:19.853] [2/4] Fetching packages...
[10:22:35.974] [3/4] Linking dependencies...
[10:22:35.976] warning " > @ducanh2912/next-pwa@9.1.4" has unmet peer dependency "webpack@>=5.9.0".
[10:22:35.976] warning "@ducanh2912/next-pwa > clean-webpack-plugin@4.0.0" has unmet peer dependency "webpack@>=4.0.0 <6.0.0".
[10:22:35.976] warning "@ducanh2912/next-pwa > terser-webpack-plugin@5.3.9" has unmet peer dependency "webpack@^5.1.0".
[10:22:35.976] warning "@ducanh2912/next-pwa > workbox-webpack-plugin@7.0.0" has unmet peer dependency "webpack@^4.4.0 || ^5.9.0".
[10:22:35.981] warning " > @typescript-eslint/eslint-plugin@5.61.0" has unmet peer dependency "@typescript-eslint/parser@^5.0.0".
[10:22:46.999] [4/4] Building fresh packages...
[10:22:47.408] Done in 27.86s.
[10:22:47.434] Detected Next.js version: 13.4.9
[10:22:47.435] Running "yarn run build"
[10:22:47.635] yarn run v1.22.17
[10:22:47.667] $ next build
[10:22:48.022] - info Loaded env from /vercel/path0/.env
[10:22:48.765] - info Creating an optimized production build...
[10:22:49.275] - info (pwa) Compiling for client (static)...
[10:22:49.275] - info (pwa) Service worker: public/sw.js
[10:22:49.275] - info (pwa) URL: /sw.js
[10:22:49.275] - info (pwa) Scope: /
[10:22:49.308] - info (pwa) Compiling for server...
[10:22:49.311] - info (pwa) Compiling for server...
[10:23:05.467] - info Compiled successfully
[10:23:05.468] - info Linting and checking validity of types...
[10:23:07.580] - error ESLint: prettier.resolveConfig.sync is not a function Occurred while linting /vercel/path0/src/@types/index.d.ts:1 Rule: "prettier/prettier"
[10:23:08.469] - info Collecting page data...
[10:23:23.191] - info Generating static pages (0/10)
[10:23:23.255] - info Generating static pages (2/10)
[10:23:23.263] - info Generating static pages (4/10)
[10:23:23.275] - info Generating static pages (7/10)
[10:23:23.531] - info Generating static pages (10/10)
[10:23:23.547] - info Finalizing page optimization...
[10:23:23.550]
[10:23:23.560] Route (app) Size First Load JS
[10:23:23.560] ┌ ○ / 6.96 kB 86.7 kB
[10:23:23.560] ├ ○ /apple-icon.png 0 B 0 B
[10:23:23.560] ├ ○ /favicon.ico 0 B 0 B
[10:23:23.560] ├ ○ /icon.png 0 B 0 B
[10:23:23.560] ├ ○ /manifest.webmanifest 0 B 0 B
[10:23:23.561] ├ ○ /opengraph-image.jpg 0 B 0 B
[10:23:23.561] ├ ○ /robots.txt 0 B 0 B
[10:23:23.562] └ ○ /sitemap.xml 0 B 0 B
[10:23:23.562] + First Load JS shared by all 79.8 kB
[10:23:23.562] ├ chunks/839-7c7d2683d752739d.js 27.3 kB
[10:23:23.562] ├ chunks/bce60fc1-a4c8f5ac12bef530.js 50.5 kB
[10:23:23.562] ├ chunks/main-app-9558a928410b261a.js 222 B
[10:23:23.562] └ chunks/webpack-355355f103a84797.js 1.71 kB
[10:23:23.562]
[10:23:23.562] Route (pages) Size First Load JS
[10:23:23.562] ─ ○ /404 181 B 77.7 kB
[10:23:23.562] + First Load JS shared by all 77.5 kB
[10:23:23.562] ├ chunks/framework-8883d1e9be70c3da.js 45 kB
[10:23:23.562] ├ chunks/main-e1e31ed019ac7d84.js 30.6 kB
[10:23:23.562] ├ chunks/pages/_app-b75b9482ff6ea491.js 195 B
[10:23:23.562] └ chunks/webpack-355355f103a84797.js 1.71 kB
[10:23:23.563]
[10:23:23.564] ○ (Static) automatically rendered as static HTML (uses no initial props)
[10:23:23.564]
[10:23:24.240] Done in 36.61s.
[10:23:27.609] Traced Next.js server files in: 3.330s
[10:23:31.719] Created all serverless functions in: 4.108s
[10:23:31.726] Collected static files (public/, static/, .next/static): 4.917ms
[10:23:32.341] Build Completed in /vercel/output [1m]
[10:23:32.570] Deploying outputs...
[10:23:39.921] Deployment completed
[10:23:45.015] Uploading build cache [107.09 MB]...
[10:23:47.458] Build cache uploaded: 2.442s |
Hmm. Both of your reproductions worked for me with What I can see is that both of you used Could you try to remove @alifa20 if you could provide the error stack, that would also be very helpful, thanks! There are also only 4 releases between |
@balazsorban44 I'm also experiencing this error using the library https://github.com/dlehmhus/next-with-linaria. At least for me the error starts in release |
@balazsorban44 Thanks for the reply.
I believe the stack error is very similar to what @Marcus-Rise has mentioned actually.
|
1 First thing I did, still worked |
@balazsorban44 Really appreciate the investigation thanks 🙏 |
I'm leaning towards #52241 being related. |
Will add a +1 to this being related to |
next-pwa isn't in our config and this is happening regardless. I can also see that webpack isn't being installed.... there is a |
Commented out import of next-pwa (Both the maintained and unmaintained version) works |
This PR ensures that both Webpack and the config won't be initiated in render workers. This is great for performance but also avoids potential issues (e.g. Next.js plugin with side effects). Instead, we pass a serialized config from the router worker to the render workers. Closes #52366.
@alifa20 can you try my fork's I moved
We also rely on certain Edit: seems that this is a Next.js issue, but this change also fixes this issue anyway :D |
@DuCanhGH Your suggested version definitely fixed the issue with existing next.js v13.4.9 . Thanks for jumping in and updating this issue thread 🙏 Also thanks to @shuding that his PR seems to fix the issue for v13.4.10-canary.5 ✅ Link to the commit of the fix next-pwa 9.2.1, next.js v13.4.9 |
That being said, @DuCanhGH you might wanna move the webpack back into devDependancy? Since the new fix doesn't need webpack to be installed, as it was before. |
@alifa20 I will wait for 13.4.10 to release first, then revert later with a note in |
@DuCanhGH |
I'm not using |
I'm using NextJS |
@jkiss @Neo-Ciber94 Please read the above messages, this was fixed in versions newer than 13.4.9. Thanks! |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 Binaries: Node: 18.16.1 npm: 9.5.1 Yarn: 1.22.19 pnpm: 8.6.6 Relevant Packages: next: 13.4.9-canary.3 eslint-config-next: 13.4.9 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
alifa20/next-js-demo#1
To Reproduce
Describe the Bug
I have a suspicion that this issue may be related to the following GitHub links:
🤷♂️ ¯\(ツ)/¯
It's unclear at the moment, so I'm not entirely certain.
However, the older version, v13.4.8, seems to be functioning properly.
Expected Behavior
Localhost:3000 should come up.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1434
The text was updated successfully, but these errors were encountered: