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
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.
…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)
…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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You didn't really explain how that's better, and the implications.
My opinion: want something better than
npm install -g? Just usenpx.That said, if you do want to use
npm install -gfor whatever reason, then no need to usenvmeither: configure aprefixsomewhere in your home directory for NPM to install to and add itsnode_modulesto yourNODE_PATH(and make sure to put itsbin/in your path).And if you're using
npm install -gto install Yarn or PNPM, consider using Corepack instead: nodejs.org/api/corepack.htmlTo me, using NVM really seems like cargocult.
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 bothnodeandnpm, are all I need to have a working environment.…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
npxyou have even fewer steps: none. 😉To update
npm, all you need to do isnpm update -glike you would do withoutnvm.nvmis simply a node version manager that lets you develop on a specificnodeversion easily (and without needing the root permission).To update
node, it'snvm install node.And for development purposes (debugging and so on), it's even better to update the system and
nodeversion separately.I believe
npmandnpxhave difference use cases.