Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>NPM will install local packages into your projects already, but I still like to keep the system away from my operating system's files. Here's how I suggest compartmentalizing Nodejs packages:</p> <p>Install Nodejs and NPM via the chris-lea PPA. Then I set up a package root in my homedir to hold the Node "global" packages:</p> <pre><code> $ NPM_PACKAGES="$HOME/.npm-packages" $ mkdir -p "$NPM_PACKAGES" </code></pre> <p>Set NPM to use this directory for its global package installs:</p> <pre><code> $ echo "prefix = $NPM_PACKAGES" &gt;&gt; ~/.npmrc </code></pre> <p>Configure your PATH and MANPATH to see commands in your $NPM_PACKAGES prefix by adding the following to your .zshrc/.bashrc:</p> <pre><code># 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" </code></pre> <p>Now when you do an <code>npm install -g</code>, NPM will install the libraries into <code>~/.npm-packages/lib/node_modules</code>, and link executable tools into <code>~/.npm-packages/bin</code>, which is in your <code>PATH</code>.</p> <p>Just use <code>npm install -g</code> as you would normally:</p> <pre><code>[justjake@marathon:~] $ npm install -g coffee-script ... (npm downloads stuff) ... /home/justjake/.npm-packages/bin/coffee -&gt; /home/justjake/.npm-packages/lib/node_modules/coffee-script/bin/coffee /home/justjake/.npm-packages/bin/cake -&gt; /home/justjake/.npm-packages/lib/node_modules/coffee-script/bin/cake coffee-script@1.3.3 /home/justjake/.npm-packages/lib/node_modules/coffee-script [justjake@marathon:~] $ which coffee /home/justjake/.npm-packages/bin/coffee </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload