There are majorly two ways to install a package for your node applications:
For local, you can use
npm i <package-name> which would install the package only for your project directory.
For global, you can use
npm i -g <package-name> which would install the package globally and the package would be accessible on your machine regardless of your project.
In brief, use
npm i -g <package-name> if you want your node package to be commonly available across all projects.
Read more here: Source link