NDDT
NDDT

Reputation: 545

Angular: Can't use ng-Command

I'm trying to install angular in a vagrant-box.

npm install -g @angular/cli

Sadly I get this error when I try using the client:

The program 'ng' is currently not installed. You can install it by typing:
sudo apt install ng-common

(ng-common seems to be a text-editor?)

does anyone know how I can get this running?

I tryied uninstalling and reinstalling.

Edits: Im running Ubuntu in the vagrant-box and I'm working only inside of it. The installation is completed even though I'm skipping two optional dependencys.

Upvotes: 2

Views: 7552

Answers (2)

Hearen
Hearen

Reputation: 7828

I encountered the same issue after installation npm install -g @angular/cli caused by the incorrect version of the node.

I solved it by using nvm to manage the node version:

nvm list; # check your local versions;
nvm install 10.10.0; # install a new remote version;
nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;

nvm list; # make sure you are using the right version;
nvm use default; # if not

Then you don't even need to reinstall angular, check it with ng -h and it will work.

Upvotes: 0

NDDT
NDDT

Reputation: 545

I found the issue:

I had installed two diffrent versions of angular-cli:

npm install -g @angular/cli
npm install -g angular-cli

The second line installs an older version which creates a conflict. You can check which versions are installed with this line:

npm list -g --depth=0

I wasn't able to "npm uninstall" it, so I remove it with "sudo rm" from the node folder.

Finally I added the path (this will work no matter where ur node is):

echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc && source ~/.bashrc

Upvotes: 9

Related Questions