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/lib/RequestShortener' after npm|yarn install was run with NODE_ENV=production #4964

Closed
vincenzo opened this issue Aug 16, 2018 · 5 comments

Comments

@vincenzo
Copy link

vincenzo commented Aug 16, 2018

Bug report

Related to #2339 but more specific.

The error:

$ next build
module.js:540
    throw err;
    ^

Error: Cannot find module 'webpack/lib/RequestShortener'
    at Function.Module._resolveFilename (module.js:538:15)
    at Function.Module._load (module.js:468:25)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/app/node_modules/friendly-errors-webpack-plugin/src/core/extractWebpackError.js:4:26)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/app/node_modules/friendly-errors-webpack-plugin/src/core/transformErrors.js:3:22)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
error Command failed with exit code 1.

Describe the bug

This error only happens when one runs next build after the app has been installed ([npm|yarn] install) in an environment that has NODE_ENV set to production.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Write or get yourself a Next app
  2. Set NODE_ENV=production
  3. npm|yarn install
  4. next build

Expected behavior

No error, build completes successfully.

System information

  • OS: Linux
  • Version of Next.js: [e.g. 5.0.0 and 5.1.0]

Additional context

Not sure whether the bug could be with Next or friendly-errors-webpack-plugin.

Workaround

I am working around this bug by simply adding webpack to my app's dependencies (not devDeps). But I shouldn't have to.

@timneutkens
Copy link
Member

I'm expecting something is wrong in your lockfile. I can't reproduce this based on the issue description, so I'm going to close the issue.

@vincenzo
Copy link
Author

Been there, done that (regenerating the lock file), didn't help. Like others in #2339, I can only work around this by adding webpack to my own app's dependencies, and I should not have to.

@olastor
Copy link

olastor commented Aug 21, 2018

+1 Having same issue. Running yarn install --prod instead of yarn install (after removing node_modules) gives me the following error when running next build

yarn run v1.9.4
$ next build
module.js:549
    throw err;
    ^

Error: Cannot find module 'webpack/lib/RequestShortener'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/mypath/node_modules/friendly-errors-webpack-plugin/src/core/extractWebpackError.js:4:26)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/mypath/node_modules/friendly-errors-webpack-plugin/src/core/transformErrors.js:3:22)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@vincenzo
Copy link
Author

If it helps, I'll add my app's deps:

"dependencies": {
    "apollo-client-preset": "^1.0.8",
    "classnames": "^2.2.5",
    "clean-css": "^4.1.11",
    "deepmerge": "^2.0.1",
    "express": "^4.16.2",
    "graphql": "^0.13.1",
    "graphql-tag": "^2.7.3",
    "isomorphic-unfetch": "2.0.0",
    "lottie-web": "^5.1.9",
    "next": "^5.1.0",
    "platformsh": "^0.0.1",
    "prop-types": "^15.6.0",
    "react": "^16.2.0",
    "react-apollo": "2.0.4",
    "react-dom": "^16.2.0",
    "react-jss": "^8.3.3",
    "react-lazyload": "^2.3.0",
    "react-no-ssr": "^1.1.0",
    "react-slick": "^0.16.0",
    "react-test-renderer": "^16.3.2",
    "tinycolor2": "^1.4.1",
    "webpack": "3.10.0"
  },

(of course, webpack is the workaround)

My lock file was generated fresh from these deps.

@jtushman
Copy link

+1 I am also having this issue @timneutkens

@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants