DEV Community

Discussion on: How to install npm AKA Node.js package manager the right way on openSUSE Linux

Collapse
 
tbroyer profile image
Thomas Broyer

You didn't really explain how that's better, and the implications.

My opinion: want something better than npm install -g? Just use npx.

That said, if you do want to use npm install -g for whatever reason, then no need to use nvm either: configure a prefix somewhere in your home directory for NPM to install to and add its node_modules to your NODE_PATH (and make sure to put its bin/ in your path).

And if you're using npm install -g to install Yarn or PNPM, consider using Corepack instead: nodejs.org/api/corepack.html

To me, using NVM really seems like cargocult.

Collapse
 
archerallstars profile image
Archer Allstars

Thanks for your suggestion ❤️

However, the reason I think this method is the best is due to its simplicity. I don't have to configure anything in my system. A command for installing nvm, and another command for installing both node and npm, are all I need to have a working environment.

Collapse
 
tbroyer profile image
Thomas Broyer

…but then you have (correct me if I'm wrong) to manually update Node and NPM (which means you have to follow the news about it), rather than simply relying on your system updates (assuming Linux here)

And with npx you have even fewer steps: none. 😉

Thread Thread
 
archerallstars profile image
Archer Allstars • Edited

…but then you have (correct me if I'm wrong) to manually update Node and NPM (which means you have to follow the news about it), rather than simply relying on your system updates (assuming Linux here)

To update npm, all you need to do is npm update -g like you would do without nvm. nvm is simply a node version manager that lets you develop on a specific node version easily (and without needing the root permission).

To update node, it's nvm install node.

And for development purposes (debugging and so on), it's even better to update the system and node version separately.

And with npx you have even fewer steps: none. 😉

I believe npm and npx have difference use cases.