Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing npm globally

Is it possible to install npm globally and is this a good idea?

I installed npm with the npm install command and was able to run npm start. Then after publishing my project to github I wanted to make sure it would run if someone cloned it, so I cloned it to a different directory on my machine. I then had to run npm install again to install the dependencies. Is it necessary to do this for each project you build locally or is it better and possible to install it globally on your machine?

Thanks

like image 687
Rich Avatar asked Jul 19 '26 04:07

Rich


1 Answers

Command line for install npm globally--

npm install -g <package>

For more read from here.

In general, the rule of thumb is:

If you’re installing something that you want to use in your program, using require('whatever'), then install it locally, at the root of your project.

If you’re installing something that you want to use in your shell, on the command line or something, install it globally, so that its binaries end up in your PATH environment variable.

Details you can read here.

like image 177
Mohammad Sadiqur Rahman Avatar answered Jul 22 '26 19:07

Mohammad Sadiqur Rahman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!