angular-cli: Can't use ng functionality ("node_modules appears empty")
Bug Report or Feature Request (mark with an x
)
After installing the cli i was able to create a new project using the cli but i’m unable to use any of the ng functionality inside my project (serve, ng g…)
Versions.
@angular/cli: 1.2.1 node: 6.11.1
Repro steps.
npm install -g @angular/cli
ng new PROJECT-NAME
cd .\PROJECT-NAME
ng serve
The log given by the failure.
node_modules appears empty, you may need to run npm install
after running ng —version i get the following errors: @angular/animations: error @angular/common: error @angular/compiler: error @angular/core: error @angular/forms: error @angular/http: error @angular/platform-browser: error @angular/platform-browser-dynamic: error @angular/router: error @angular/cli: error @angular/compiler-cli: error @angular/language-service: error
Mention any other details that might be useful.
-I followed exactly as instructed by the installation.
- Uninstalled and installed nodeJS
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 16 (1 by maintainers)
I had the same issue but this is because i was running the command outside of the root dir. Just wanted to point that out in case someone has the same issue.
My solution:
My project was at myproject/project. I was running
ng serve
from my project folder without problems, but suddenly it came up with this error. I tried reinstalling angular, rebuilding my app, nothing worked.I just ran
ng serve
from the folder project, and that was it.First sorry for my bad English.
I new in the Angular world but I really like clean things so I suggest to follow these steps to prevent more problems:
$ npm uninstall -g @angular/cli
%AppData%\npm\node_modules\
and delete the@angular
folder manually%AppData%\npm-cache\
folder tooNow you uninstalled everything which have connection with Angular (I think).
$ npm install -g @angular/cli
(if you go back to%AppData%\npm\node_modules\
you can see the@angular
folder again)$ cd C:\xampp\htdocs\
)$ ng new MyFirstAngularProject
$ cd MyFirstAngularProject
$ rm -rf package-lock.json node_modules && npm install
If I am not wrong this install every Angular dependency locally so this command will create anode_modules
folder inside theC:\xampp\htdocs\MyFirstAngularProject
folder.ng serve
command.I not tried but somebody will correct me if I am wrong but I think you don’t have to run the
$ npm install -g @angular/cli
command because you can download Angular where is an Angular project or will be.1- cmd > run ng version , to confirm that angular CLI was installed correctly
2- Be Sure that you are in the right direction like d: cd “D:\NewApp\angular4app” then run : ng serve