nestjs / nest-cli

CLI tool for Nest applications 🍹
https://nestjs.com
Other
1.97k stars 394 forks source link

Error Cannot find module 'webpack' #2680

Closed amanbabbar-kipl closed 3 months ago

amanbabbar-kipl commented 3 months ago

Is there an existing issue for this?

Current behavior

I have a Nestjs application when I run the Nest build command it fails with the error: Cannot find module 'webpack'

Ubuntu: 22.04.2 LTS x86_64 Node v20.11.0 Npm v10.2.4

I have to install the webpack package and then restart my app manually. I have other nestjs projects on the same ubuntu server and don't have any issues with them during the build command

Error:

Error Cannot find module 'webpack' Require stack:

/var/node/nestjs-demo/node_modules/fork-ts-checker-webpack-plugin/lib/issue/issue-webpack-error.js /var/node/nestjs-demo/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tap-after-compile-to-get-issues.js /var/node/nestjs-demo/node_modules/fork-ts-checker-webpack-plugin/lib/hooks/tap-start-to-run-workers.js /var/node/nestjs-demo/node_modules/fork-ts-checker-webpack-plugin/lib/plugin.js /var/node/nestjs-demo/node_modules/fork-ts-checker-webpack-plugin/lib/index.js /var/node/nestjs-demo/node_modules/@nestjs/cli/lib/compiler/defaults/webpack-defaults.js /var/node/nestjs-demo/node_modules/@nestjs/cli/lib/compiler/webpack-compiler.js /var/node/nestjs-demo/node_modules/@nestjs/cli/actions/build.action.js /var/node/nestjs-demo/node_modules/@nestjs/cli/actions/index.js /var/node/nestjs-demo/node_modules/@nestjs/cli/commands/command.loader.js /var/node/nestjs-demo/node_modules/@nestjs/cli/commands/index.js /var/node/nestjs-demo/node_modules/@nestjs/cli/bin/nest.js

Minimum reproduction code

nest build

Steps to reproduce

  1. npm install
  2. nest build
  3. same error Error Cannot find module 'webpack'

Expected behavior

nest cli should install webpack package and it nest build command should build the project

Package version

10.4.2

NestJS version

10.3.0

Node.js version

20.11.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 3 months ago

Thank you for taking the time to submit your report! From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.