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)

Most upvoted comments

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:

  • Uninstall every Angular thing
    • delete the files/folders what you downloaded from Angular’s GitHub page.
    • type this to the terminal: $ npm uninstall -g @angular/cli
      • or go to %AppData%\npm\node_modules\ and delete the @angular folder manually
      • and the %AppData%\npm-cache\ folder too

Now you uninstalled everything which have connection with Angular (I think).

  • Install Angular CLI
    • type $ npm install -g @angular/cli (if you go back to %AppData%\npm\node_modules\ you can see the @angular folder again)
  • select the path in your terminal where you want to place your Angular project (for example: $ cd C:\xampp\htdocs\)
  • Create a new Angular app: $ ng new MyFirstAngularProject
  • Go inside the project: $ cd MyFirstAngularProject
  • Do what I suggested above: $ 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 a node_modules folder inside the C:\xampp\htdocs\MyFirstAngularProject folder.
  • And after that you have to start the server to run the Angular app with the 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

image

2- Be Sure that you are in the right direction like d: cd “D:\NewApp\angular4app” then run : ng serve