question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module 'webpack' in CI environment

See original GitHub issue

Bug report

Describe the bug

In CI environments, when initially trying to start the server after build, it errors out with the following error:

ERR Error: Cannot find module 'webpack'
ERR Require stack:
ERR - /home/vcap/deps/0/node_modules/mini-css-extract-plugin/dist/index.js
ERR - /home/vcap/deps/0/node_modules/mini-css-extract-plugin/dist/cjs.js
ERR - /home/vcap/deps/0/node_modules/@zeit/next-css/css-loader-config.js
ERR - /home/vcap/deps/0/node_modules/@zeit/next-sass/index.js
ERR - /home/vcap/app/next.config.js
ERR - /home/vcap/deps/0/node_modules/next/dist/next-server/server/config.js
ERR - /home/vcap/deps/0/node_modules/next/dist/next-server/server/next-server.js
ERR - /home/vcap/deps/0/node_modules/next/dist/server/next.js
ERR - /home/vcap/app/routes/next.js
ERR - /home/vcap/app/helpers/startServer.js
ERR - /home/vcap/app/server.js
ERR     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
ERR     at Function.Module._load (internal/modules/cjs/loader.js:527:27)
ERR     at Module.require (internal/modules/cjs/loader.js:683:19)
ERR     at require (internal/modules/cjs/helpers.js:16:16)
ERR     at Object.<anonymous> (/home/vcap/deps/0/node_modules/mini-css-extract-plugin/dist/index.js:7:16)
ERR     at Module._compile (internal/modules/cjs/loader.js:776:30)
ERR     at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
ERR     at Module.load (internal/modules/cjs/loader.js:643:32)
ERR     at Function.Module._load (internal/modules/cjs/loader.js:556:12)
ERR     at Module.require (internal/modules/cjs/loader.js:683:19) {
ERR   code: 'MODULE_NOT_FOUND',
ERR   requireStack: [
ERR     '/home/vcap/deps/0/node_modules/mini-css-extract-plugin/dist/index.js',
ERR     '/home/vcap/deps/0/node_modules/mini-css-extract-plugin/dist/cjs.js',
ERR     '/home/vcap/deps/0/node_modules/@zeit/next-css/css-loader-config.js',
ERR     '/home/vcap/deps/0/node_modules/@zeit/next-sass/index.js',
ERR     '/home/vcap/app/next.config.js',
ERR     '/home/vcap/deps/0/node_modules/next/dist/next-server/server/config.js',
ERR     '/home/vcap/deps/0/node_modules/next/dist/next-server/server/next-server.js',
ERR     '/home/vcap/deps/0/node_modules/next/dist/server/next.js',
ERR     '/home/vcap/app/routes/next.js',
ERR     '/home/vcap/app/helpers/startServer.js',
ERR     '/home/vcap/app/server.js'
ERR   ]
ERR }

It seems there is an issue with the mini-css-extract-plugin as part of @zeit/next-sass. We’ve been successfully using this plugin for over a year, with different versions of next.js from 6.0 up to 9.2, and a seemingly unrelated commit is now introducing this error that prevents the site from starting.

This was reported previously in the mini-css-extract-plugin repo: https://github.com/webpack-contrib/mini-css-extract-plugin/issues/198

To Reproduce

I know this isn’t helpful, but I’m unable to provide a repository at this time.

Expected behavior

The app should start.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: Linux
  • Version of Next.js: 9.2.2, “@zeit/next-sass”: “^1.0.1”,
  • Version of Node.js: 12.6.0

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
isggwpcommented, Feb 2, 2021

it happens in next 10.0.6 . we need reproduce

3reactions
ashispavancommented, Jan 21, 2021

I am facing this issue after upgrading to NextJS 10. It only happens in CI env. @robianmcd Were you able to figure out a workaround for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Error: Cannot find module 'webpack' - Stack Overflow
Error: Cannot find module 'webpack' is a node error. So this has nothing to do with webpack itself (afaict). It seems like node...
Read more >
How to fix Error: cannot find module "webpack" - Educative.io
1. Install webpack in the local app folder · 2. Link webpack to your project.
Read more >
Error: Cannot find module 'webpack' · Issue #21679 - GitHub
I just updated to 10.0.6 version from 10.0.5 and im getting the next error: Error: Cannot find module 'webpack'. I found out that...
Read more >
Cannot find module 'webpack-cli' error | bobbyhadz
To solve the "Cannot find module 'webpack-cli'" error, make sure to install webpack-cli globally by running the npm i -g webpack-cli command and...
Read more >
MikysIta - Netlify Support Forums
The error is : Dependencies installation error Cannot find module '…/webpack-runtime.js' Before this error I had a similar one th…
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found