4

As you can see, I have version 9 installed regularly.

npm install -g @angular/cli npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142 /home/user/.npm-global/bin/ng -> /home/user/.npm-global/lib/node_modules/@angular/cli/bin/ng > @angular/[email protected] postinstall /home/user/.npm-global/lib/node_modules/@angular/cli > node ./bin/postinstall/script.js + @angular/[email protected] updated 1 package in 8.412s ┌─────────────────────────────────────────────────────────┐ │ npm update check failed │ │ Try running with sudo or get access │ │ to the local update config store via │ │ sudo chown -R $USER:$(id -gn $USER) /home/user/.config │ └─────────────────────────────────────────────────────────┘ user@computer:~$ npm list -g /home/user/.npm-global/lib ├─┬ @angular/[email protected] 

But when ever I create new app with 'ng new app-name' I get version 8 installed. When I check for the version with 'ng --version' it says that v8 is installed.

ng --version Angular CLI: 8.0.3 Node: 12.16.2 OS: linux x64 Angular: ... Package Version ------------------------------------------------------ @angular-devkit/architect 0.800.3 @angular-devkit/core 8.0.3 @angular-devkit/schematics 8.0.3 @schematics/angular 8.0.3 @schematics/update 0.800.3 rxjs 6.4.0 

Can anyone help me?

3
  • I replaced images with err txt. I rarely post here, so I forgot about the rule. Thx @Rob Commented Apr 19, 2020 at 13:20
  • 2
    Could you try to uninstall Angular CLI with npm uninstall -g @angular/cli. After that cleaning the npm cache: npm cache clean --force. After that install Angular CLI with npm install -g @angular/cli again? Commented Apr 19, 2020 at 13:40
  • I tried that many times, and again, nothing happens. I even reinstalled nvm, node, npm but ng v8 is still pressent... even though I didn't install it? how is that even possible? Commented Apr 19, 2020 at 14:11

3 Answers 3

15

Note for nvm users:

If prior to nvm installation you had @angular/cli globally installed and you are now using a different node version which you installed through nvm, then you might find the notes below useful:

When you switch your node version through nvm the npm folder location where your global node_modules are installed.

Let's say I switched to node 14 (nvm use 14) and installed the latest angular cli using:

npm install @angular/cli -g

You will see an output telling you that angular was successfully installed. Then you run ng --version to verify the version and you realize the old version is still there. Why?

NVM's node is located at: /Users/<USER_NAME>/.nvm/versions/node/v14.XX.XX/bin

After install @angular/cli globally a ng shortcut/symlink is placed inside this folder.

lrwxr-xr-x 1 X staff 39 14 Ago 10:45 ng -> ../lib/node_modules/@angular/cli/bin/ng -rwxr-xr-x 1 X staff 76198080 11 Ago 06:29 node lrwxr-xr-x 1 X staff 38 14 Ago 10:42 npm -> ../lib/node_modules/npm/bin/npm-cli.js lrwxr-xr-x 1 X staff 38 14 Ago 10:42 npx -> ../lib/node_modules/npm/bin/npx-cli.js 

So, it points to the node 14 node_modules folder which is located at: /Users/<USER_NAME>/.nvm/versions/node/v14.XX.XX/lib/node_modules

But since I had @angular/cli installed globally prior to nvm installation, the old version is getting on the way

To fix this, you must find where global node_modules were installed prior to NVM installation. In my case the path is: /usr/local/lib/node_modules.

Go to the folder and remove the @angular. Restart your terminal and run ng --version. You should now get the correct ng version.

This applies to other modules too.

Sign up to request clarification or add additional context in comments.

3 Comments

this comment is underrated nice explain how its work i'm clearly understand now
Took me a while to find this answer and it saved the day!
It worked. After removing the folder I had to set my node version via nvm again and installed angular cli globally again.
1

Your user does not have access to write the angular cli directory. The solution is suggested by npm in your terminal, run this command and see if your problem goes away.

 sudo chown -R $USER:$(id -gn $USER) /home/user/.config 

2 Comments

I installed nvm just so I don't have to use sudo, and I feel very uneasy to use 'chown' as I'm afraid that might have impact on some of my projects... How could I make sure this will not have effect on them?
Try these steps if you are nervous about sudo, make sure to keep the code in your home directory so you own it. This is the procedure : stackoverflow.com/questions/48910876/…
0

So I uninstalled nodejs and npm and reinstalled them with nvm. I ended with no other choice but to run sudo chown -R $USER:$(id -gn $USER) /home/user/.config and risk affecting my projects. Luckily everything was fine. Than I had an issue with nvm settings not being persistent, but I fixed it with this advice.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.