I just started learning Angular 4, and as part of learning process i did the following:
Install Node.js (version 8)
.
Ran this command npm install -g @angular/cli
created a new project through CLI: ng new my-first-app
As soon as i ran this command: ng serve
, i got an error node_module
appear empty, you may need to run 'npm install'. Once i run npm install, it installed a few libraries and now ng serve
builds and runs the project. i am trying to understand why did i need to npm install
and what did it install? shouldn't all the prerequisites have been installed with this command npm install -g @angular/cli
This error happens when there are missing packages in your node_modules/ folder that prevents the development server from running. To solve this error, you need to make sure that you have the node_modules/ folder generated by the npm install command.
So what is the problem? Try npm uninstall -g angular-cli & npm cache clear . Then install the global CLI again.
ng serve command builds and serve the application. It rebuilds the application if changes occur. Here project is the name of the application as defined in angular.
When you create an angular app from terminal
ng new my-first-app
you usually be one folder level up in the terminal. Navigate to your project path
cd my-first-app
and run
npm install
it should get resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With