Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng serve throws node_modules appears empty error

Tags:

angular

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

like image 753
Baahubali Avatar asked Sep 19 '17 11:09

Baahubali


People also ask

Why is my Node_modules empty?

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.

Why ng serve command is not working?

So what is the problem? Try npm uninstall -g angular-cli & npm cache clear . Then install the global CLI again.

What happens when Ng serve executed?

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.


1 Answers

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.

like image 68
Hemanth Bidare Avatar answered Sep 25 '22 13:09

Hemanth Bidare