I have cloned an angular 4 project from git.
When I go to the root folder of the project and did ng serve.
I am getting following error. node_modules appears empty, you may need to run npm install
how can I fix the above error.
Run npm install
from the root of the project. If you're on a mac then you may want to run sudo npm install
in case some of the package installations require elevated permissions. If it has submodules then leave a comment below and I'll update this answer to include how to deal with those. No use in confusing this answer with that unless you hit it.
Open the directory where your project is using cd (Project name) Then run the command npm install After then you can easily run the ng g component command
Its saying node_module is empty means its not getting path.
1st Check path.Go to that path Using cd Like 'cd C:\Windows\UrProjectName'
Then run ng serve in node command prompt.
In this situation you right click the app.component.html module then click a open in terminal.
After the terminal is opened in a bottom,you just type the command ng serve.
It can be worked properly.Each and every time you run the project in this method you avoid these types of errors.
来源:https://stackoverflow.com/questions/47097772/node-modules-appears-empty-you-may-need-to-run-npm-install