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' on fresh installation

See original GitHub issue

I have a fresh installation of NX for React project; I got this message when try to serve the React project from VSCode NX toolkit.

> Executing task: nx serve fe-ui-compoents <


> nx run fe-ui-compoents:serve 
Cannot find module 'webpack'
Require stack:
- /Users/nv/projects/x/y/node_modules/webpack-dev-server/lib/Server.js
- /Users/nv/projects/x/y/node_modules/@nrwl/web/src/executors/dev-server/dev-server.impl.js
- /Users/nv/projects/x/y/node_modules/@nrwl/tao/src/shared/workspace.js
- /Users/nv/projects/x/y/node_modules/@nrwl/tao/src/commands/run.js
- /Users/nv/projects/x/y/node_modules/@nrwl/tao/index.js
- /Users/nv/projects/x/y/node_modules/@nrwl/cli/lib/run-cli.js

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

>  NX   ERROR  Running target "fe-ui-compoents:serve" failed

  Failed tasks:
  
  - fe-ui-compoents:serve

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:29 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
fabiano-amaralcommented, Nov 22, 2021

Same problem here after a fresh installation, using angular project, solved with:

npm install --save-dev webpack

npm install --save-dev webpack-dev-server
2reactions
ngfelixlcommented, Dec 12, 2021

I faced the same problem with

  • npx create-nx-workspace -> preset: empty
  • npm i --save-dev @nrwl/angular
  • npx nx g @nrwl/angular:application -> name: app
  • npx nx run app:build

Installed nx version is 13.3.1

Resulting in

Cannot find module 'webpack'
Require stack:
- C:\Users\felix\Documents\development\felixlemke\node_modules\@angular-devkit\build-webpack\src\webpack\index.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@angular-devkit\build-webpack\src\index.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@angular-devkit\build-angular\src\builders\browser\index.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@angular-devkit\architect\node\index.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@nrwl\tao\src\commands\ngcli-adapter.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@nrwl\tao\src\commands\run.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@nrwl\tao\index.js
- C:\Users\felix\Documents\development\felixlemke\node_modules\@nrwl\cli\lib\run-cli.js

Resolved the build and serve target issue by installing webpack manually:

npm i --save-dev webpack
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 >
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 >
Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/ module...
Read more >
MikysIta - Netlify Support Forums
Dependencies installation error. Cannot find module '…/webpack-runtime.js'. Before this error I had a similar one that could not find theΒ ...
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