Rajneesh Mishra
Rajneesh Mishra

Reputation: 41

Getting error on angular version command

When I execute ng -v it shows:

bash: /usr/local/lib/node_modules/@angular/cli/bin/ng: No such file or directory.

I tried doing the solution in bash /usr/bin/ng: No such file or directory in Angular but could not find node_modules folder in /usr/local/lib folder. Even after running sudo npm install @angular/[email protected], I get the same error.

Any help please

Upvotes: 1

Views: 6781

Answers (3)

Lukas Sorensen
Lukas Sorensen

Reputation: 407

You need to install the package globally

sudo npm i -g @angular/[email protected]

Upvotes: 1

Rajneesh Mishra
Rajneesh Mishra

Reputation: 41

I was able to solve it. Just for info if any one is willing to know

1) npm uninstall -g angular-cli
2) npm cache clean --force
3) sudo npm install -g @angular/[email protected]
4) added line 'alias ng="/home/XXXXXX/.npm-global/lib/node_modules/@angular/cli/bin/ng"' in ~/.bashrc

Created a new terminal and checked ng -v and it worked.

I want to create a pwa app so i hope cli 6.2 should work fine

Upvotes: 1

Xinan
Xinan

Reputation: 3162

I've been experienced the exact same error previously. In my case, it was caused by running this command in the wrong place that has unnecessary package.json and package-lock.json in an outdated format.

Please double check if you are executing ng -v in the correct path, and both package.json and package-lock.json are updated in the correct states.

Upvotes: 1

Related Questions