Posted 5 months ago. Visible to the public. Linked content. Deprecated.

How to install npm packages globally without sudo on Linux

We use NVM instead, where this is not an issue.

All quoted.

  1. Set up a package root in your homedir to hold the Node "global" packages:

    Copy
    $ NPM_PACKAGES="$HOME/.npm-packages" $ mkdir -p "$NPM_PACKAGES"
  2. Set NPM to use this directory for its global package installs:

    Copy
    $ echo "prefix = $NPM_PACKAGES" >> ~/.npmrc
  3. Configure your PATH and MANPATH to see commands in your $NPM_PACKAGES prefix by adding the following to your .bashrc:

    Copy
    # NPM packages in homedir NPM_PACKAGES="$HOME/.npm-packages" # Tell our environment about user-installed node tools PATH="$NPM_PACKAGES/bin:$PATH" # Unset manpath so we can inherit from /etc/manpath via the `manpath` command unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration MANPATH="$NPM_PACKAGES/share/man:$(manpath)" # Tell Node about these packages NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"

Now when you do an npm install -g, NPM will install the libraries into ~/.npm-packages/lib/node_modules link executable tools into ~/.npm-packages/bin, which is in your PATH.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Avatar
Dominik Schöler
Last edit:
4 months ago
by Besprechungs-PC
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more