6

Reinstall global packages after updating node using NVM

 10 months ago
source link: https://barryvanveen.nl/articles/3ebc85ec-reinstall-global-packages-after-updating-node-using-nvm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Reinstall global packages after updating node using NVM

Sep 21, 2023

Node Version Manager (nvm) is a tool I use on a daily basis. Lately, we have upgraded some projects to newer Node versions and this is causing some problems.

The problem

My global packages (like cdk) were installed when I was still running version 16. Now I'm running version 18 and those packages are not globally available anymore.

The same can happen when running nvm install upgrades Node to a new minor or patch version.

The solution

Next time this happens to you, follow these steps:

  • Run nvm list to find the previously installed version, the one that "contains" the global packages
  • Run nvm reinstall-packages <previousVersion> to get your global packages back.

Bonus

If you want to get a list of all globally installed packages, run npm list -g --depth 0.

Comments (0)

Got a question? Liked the article or got a suggestion? Leave a comment to let us know.

Name

Email address (not visible to others)

Message


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK