Angular-cli: Error installing angular-cli on Ubuntu

Created on 6 Oct 2016  路  23Comments  路  Source: angular/angular-cli

On Ubuntu 14 & 16
Node version: 6.7.0
Npm version: 3.10.3

>$ npm install -g [email protected] 
>$ ng -v
>$ The program 'ng' is currently not installed. You can install it by typing:
sudo apt-get install ng-common

The output seems like angular-cli is correctly installed. I've fixed the npm sudo permissions.

more info

Most helpful comment

i have the same problem . i solve it as follow:

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

it works for me !

All 23 comments

Same here

/usr/lib/node_modules/angular-cli/node_modules/portfinder/lib/portfinder.js:395
  var interfaces = os.networkInterfaces(),
                      ^

Error: EINVAL: invalid argument, uv_interface_addresses
    at Error (native)
    at /usr/lib/node_modules/angular-cli/node_modules/portfinder/lib/portfinder.js:395:23
    at Object.<anonymous> (/usr/lib/node_modules/angular-cli/node_modules/portfinder/lib/portfinder.js:410:2)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)

Try installing it with sudo user

sudo npm install -g angular-cli

Nop. I tried with sudo.

Same here

This might be a general npm problem.

Can you please try the following steps and report the result?

First, run npm bin -g and ensure you have full permissions on the folder that gets printed as a result of this command.

Then run the following series of commands:

sudo npm rm -g angular-cli
npm cache clear
sudo npm install -g angular-cli

Does this solve the problem?

npm bin -g
/home/cloud/.npm-global/bin

I've the permissions in that folder and the path is included in the PATH env variable.

After running all those commands, nothing changes, ng command does not exist in the /home/cloud/.npm-global/bin folder

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

This might be a silly question, but are you sure your npm bin path is on the PATH? For instance, can you use other npm packages globally?

yes @filipesilva, I can also install and use other global packages like jshint or typescript. It is too weird...

I've created an ubuntu droplet in DigitalOcean twice and it is still happening.

When I run npm install -g [email protected] the output is ok, but in the npm bin -g folder, ng command is not there.

Content of npm bin -g folder

jshint  node  npm  tsc  tsserver

the solution is here https://github.com/angular/angular-cli/issues/1192

It was a memory issue, my system had only 512mb of ram memory

i have the same problem . i solve it as follow:

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

it works for me !

On Ubuntu 16.04 my working solution is sudo npm install --unsafe-perm -g @angular/cli

Solved!

I got the same problem because using two versions of node by nvm

Add to your .bachrc file all versions of your nodes!

PATH=.../.nvm/versions/node/v0.12.15/bin:.../.nvm/versions/node/v8.1.3/bin:

cheers!

Hello ,
my name is Alex Silva, I had the same problem and was resolved using this command sudo npm install --unsafe-perm -g @angular/cli

Thanks you very much

@silva130690 I am trying your option on ubuntu 16.04 and it is showing that it can not parse JSON as javascript error.

@richard457 Open terminal and run command whit permission administrator : Sudo ... Script

Understood ?

Thank you commercialsuicide ..
you have save my day.

@commercialsuicide yep your solution worked a treat,

sudo npm install --unsafe-perm -g @angular/cli

seems to do the trick. But could anyone explain why

npm install -g ng

doesn't work?

and also why the recommended

sudo apt install ng-common

doesn't work, once installed "ng build" it seems to completely freeze my screen and not allow me to do anything.

It's work after installing globally using the below command
npm install -g angular-cli@version_number

Note: Make sure you have same version of @angulasr/cli as your project has or else it will show warning when building project.

i have the same problem . i solve it as follow:

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

it works for me !

This worked for me!! Thanks!

i have the same problem . i solve it as follow:
$: echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc && source ~/.bashrc
$:ng -v
it works for me !

This worked for me!! Thanks!

I solved this problem by running the following command:
$: echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc && source ~/.bashrc

Hello,
you will find here the steps to Install Angular 9 on Ubuntu 19.10 , 18.04 & 16.04
https://newsanddevelopments.blogspot.com/2020/04/how-to-install-angular-9-on-ubuntu-1804.html

anybody, i cant install angular on ubuntu 20.4

Was this page helpful?
0 / 5 - 0 ratings