More actions
Add info on global NPM packages |
m Twonum moved page Installing Global NPM Packages to Installing Global npm Packages |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
By default, | By default, npm installs global packages to <code>/usr</code>, which requires root permissions. If you would like to install global npm packages on Nest, you'll need to configure npm to install global packages to your home directory. | ||
This can be done using the [https://docs.npmjs.com/cli/v10/commands/npm-prefix prefix config]: | This can be done using the [https://docs.npmjs.com/cli/v10/commands/npm-prefix prefix config]: | ||
| Line 7: | Line 7: | ||
</pre> | </pre> | ||
Now, global packages will be installed to <code>~/.local/lib/node_modules/</code>, and binaries will be placed in <code>~/.local/bin/</code>. [https://docs.npmjs.com/cli/v10/configuring-npm/folders More info on | Now, global packages will be installed to <code>~/.local/lib/node_modules/</code>, and binaries will be placed in <code>~/.local/bin/</code>. [https://docs.npmjs.com/cli/v10/configuring-npm/folders More info on npm folders] | ||
'''However''', by default, <code>~/.local/bin/</code> is not on the PATH, so you won't be able to execute globally-installed binaries without specifying their full paths. | '''However''', by default, <code>~/.local/bin/</code> is not on the PATH, so you won't be able to execute globally-installed binaries without specifying their full paths. | ||
Latest revision as of 01:07, 26 July 2025
By default, npm installs global packages to /usr, which requires root permissions. If you would like to install global npm packages on Nest, you'll need to configure npm to install global packages to your home directory.
This can be done using the prefix config:
$ npm config --location=user set prefix=$HOME/.local
Now, global packages will be installed to ~/.local/lib/node_modules/, and binaries will be placed in ~/.local/bin/. More info on npm folders
However, by default, ~/.local/bin/ is not on the PATH, so you won't be able to execute globally-installed binaries without specifying their full paths.
Nest admins are working on adding this to the PATH by default, but you can also add it to your PATH by adding this to your shell's configuration file. (For Bash, this is ~/.bashrc):
export PATH="$PATH:~/.local/bin"