npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently. It is extremely configurable to support a wide variety of use cases. Most commonly, it is used to publish, discover, install, and develop node programs.
the -g flag means install the package globally on your system.
The G (go) command moves to a specified line and displays it. It can move both backward and forward from the current line. The G command displays one line at a time. [G][n]
npm install -g pm2 - pm2 will be installed globally. It will then typically be found in /usr/local/lib/node_modules (Use npm root -g to check where.) If you're using nvm, then your global modules may be in one of several places depending on the version of node you're using at the time.
-g
is the global install flag, as explained in this answer. It's covered in detail in this node blog post.
The rules of thumb:
While the accepted answer is correct, be aware that there is also npx
which allows to conveniently run local tools.
For more information, see https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With