Skip to content
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

Cannot find module 'webpack' in CI environment #12288

Closed
tortilaman opened this issue Apr 28, 2020 · 17 comments
Closed

Cannot find module 'webpack' in CI environment #12288

tortilaman opened this issue Apr 28, 2020 · 17 comments
Labels
please add a complete reproduction The issue lacks information for further investigation

Comments

@tortilaman
Copy link

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: webpack-contrib/mini-css-extract-plugin#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.

@timneutkens timneutkens added the please add a complete reproduction The issue lacks information for further investigation label Apr 29, 2020
@timneutkens
Copy link
Member

This issue is not actionable so I'm not sure what to do here.

@tortilaman
Copy link
Author

I seem to have found a workaround, so while not an issue for me, maybe an issue for others?

@timneutkens
Copy link
Member

Will close this issue then as no reproduction is provided so we can't investigate.

@robianmcd
Copy link

I'm running into this issue too. @tortilaman what was your workaround?

@Danelund
Copy link

I have this as well

@Danelund
Copy link

running

I'm running into this issue too. @tortilaman what was your workaround?

npm i --save @zeit/next-sass fixes this for me

@tortilaman
Copy link
Author

Thanks @Danelund. I no longer had access to the repo I was working on when I encountered this bug, so wasn't really able to figure out the solution I came to.

@ashispavan
Copy link

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?

@geun
Copy link

geun commented Jan 30, 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?

Same here

@MrNghia123
Copy link

Next 10 run successfully for several builds for me 3 days ago, now it started to show the same error.
Downgraded to 9.5.5 and build successfully.

@soly2014
Copy link

same issue here

@iampeterbanjo
Copy link

Rolling back to [email protected] fixes webpack dependency.

@blaxk
Copy link

blaxk commented Feb 1, 2021

In the package-lock.json file of the [email protected].* version, I noticed the difference from the [email protected] version.
I noticed that the webpack dependencies disappeared in the package-lock.json file of the [email protected].* version.

If you add webpack to package.json, you can use it without rollback.

"dependencies": {
    "webpack": "^4.46.0"
}

@saifbechan
Copy link

@blaxk I can confirm this works indeed. My version of webpack is higher.

"webpack": "^5.19.0"

@isggwp
Copy link

isggwp commented Feb 2, 2021

it happens in next 10.0.6 . we need reproduce

@timneutkens
Copy link
Member

#21679 (comment)

@balazsorban44
Copy link
Member

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.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
please add a complete reproduction The issue lacks information for further investigation
Projects
None yet
Development

No branches or pull requests