Angular-cli: Proposal: detect the absence of the `node_modules` folder while running `ng build` or `ng serve`

Created on 28 Jul 2020  路  3Comments  路  Source: angular/angular-cli

馃殌 Feature request

Command

  • [x] build
  • [x] serve

Description

Running ng build or ng serve in a folder without node_modules present results in the following error thrown in terminal:

$ ng serve
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
... stacktrace ...
See "/private/var/folders/7d/r6b3nrdj7bn9t_w_dclm6y9r00kg80/T/ng-PRpMHw/angular-errors.log" for further details.

This can happen for example after downloading an example app from angular.io website. Example link:

https://angular.io/generated/zips/form-validation/form-validation.zip

Describe the solution you'd like

The proposal is to handle the case when node_modules folder is not present and output a user-friendly error message that would suggest to run npm install or yarn install.

angulacli low inconvenient bufix

Most helpful comment

Instead of showing a message, how if we automatically do npm install or yarn install

All 3 comments

Instead of showing a message, how if we automatically do npm install or yarn install

Such errors seems to be mind-boggling when I was very new to Angular.
These needs to be exact and clear to the end user.

Same with ng new ap --skip-install && cd ap && ng version

This is somehow related to https://github.com/angular/angular-cli/issues/10474

Was this page helpful?
0 / 5 - 0 ratings