`npm run nx serve` fails after creating empty workspace, adding Angular plugin + creating new app
See original GitHub issueCurrent Behavior
npm run nx serve
fails after creating empty workspace, adding Angular plugin + creating a new application.
The message An unhandled exception occurred: Cannot find module 'webpack'
is shown.
(Note that I am starting with an empty workspace rather than with the single Angular application template because I want to customize the options for the new Angular project as shown in the reproduction steps below.)
Expected Behavior
I expect npm run nx serve
to start the Angular development server without errors.
Steps to Reproduce
On Windows 10 with NodeJS LTS 14.15.0:
- Open a new PowerShell window
- Run
npx create-nx-workspace nxtest
- Choose the ‘empty’ template and the ‘Angular CLI’ option for the CLI
- Move into the new directory with
cd nxtest
- Run
npm install -D @nrwl/angular
to install the Angular plugin - Create a new Angular app as follows:
npm run nx g @nrwl/angular:app -- testapp --e2e-test-runner=protractor --unit-test-runner=jest --strict --style=scss --routing --linter=eslint --enable-ivy
- Run
npm run nx serve
Failure Logs
PS C:\Users\<username>\source\repos\nxtest> npm run nx serve
> nxtest@0.0.0 nx
> nx "serve"
> ng run testapp:serve
An unhandled exception occurred: Cannot find module 'webpack'
Require stack:
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\build-webpack\src\webpack\index.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\build-webpack\src\index.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\build-angular\src\dev-server\index.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\architect\node\index.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular\cli\models\architect-command.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular\cli\commands\run-impl.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular\cli\models\command-runner.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@angular\cli\lib\init.js
- C:\Users\<username>\source\repos\nxtest\node_modules\@nrwl\cli\lib\run-cli.js
See "C:\Users\<USERNAME>~1\AppData\Local\Temp\ng-U7gsfD\angular-errors.log" for further details.
npm ERR! code 1
npm ERR! path C:\Users\<username>\source\repos\nxtest
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "nx "serve""
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<username>\AppData\Local\npm-cache\_logs\2020-11-06T15_10_51_278Z-debug.log
Environment
Windows 10 Pro Version 10.0.19042 Build 19042 PowerShell version: 5.1.19041.610 NodeJS version: 14.15.0
nx report output:
nx : Not Found
@nrwl/angular : 10.3.2
@nrwl/cli : 10.3.2
@nrwl/cypress : 10.3.2
@nrwl/eslint-plugin-nx : 10.3.2
@nrwl/express : Not Found
@nrwl/jest : 10.3.2
@nrwl/linter : 10.3.2
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 10.3.2
@nrwl/web : Not Found
@nrwl/workspace : 10.3.2
typescript : 4.0.5
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:17 (4 by maintainers)
Top Results From Across the Web
nrwl-nx/community - Gitter
Hello Everyone. I am trying to test a fetch endpoint but am running into cors issue. is there a way to create a...
Read more >create-nx-workspace - CLI command
Create a new Nx workspace. ... appName. Type: string. The name of the application when a preset with pregenerated app is selected ...
Read more >@nrwl/web - npm
The Nx Plugin for Web Components contains generators for managing Web Component applications and libraries within an Nx workspace.
Read more >Building Full-Stack Applications Using Angular CLI and Nx
Nx is just an extension for the Angular CLI, so create-nx-workspace simple runs ng new myorg --collection=@nrwl/schematics and handles common pitfalls of ...
Read more >Angular workspace configuration
Configures defaults for creating a Universal application with server-side rendering, using the ng run <project>:server command. architect/app-shell, Configures ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m getting the same issue. Following steps like mentioned above (which seem to be a short version of this migration overview guide).
I’m running this on Ubuntu 20.04 in WSL2. NPM version is 7.6.2.
After I get the error about missing webpack module, I can
npm i --save-dev webpack
to get webpack installed, then thenx serve
seems to get a bit further but then errors out with:EDIT: This only happens using the empty template and steps in that migration guide. If I create a new angular workspace everything works as expected. It seems like the migration guide is missing a step or two?
Any news? This seems vital to the purpose of Nx!