11

When node (v.0.10.33) is installed with homebrew (v. 0.9.5), at one point it says:

==> Caveats
If you update npm itself do NOT use the npm upgrade command
Instead execute:
npm install -g npm@latest

So, what exactly is npm upgrade and what is the difference with npm install -g npm@latest?

-- edit 2015

the problem doesn't exist anymore with the current version of node. (but I never had an answer to what npm upgrade is?)

François Romain
  • 13,617
  • 17
  • 89
  • 123

2 Answers2

8

Use npm install to install a package and npm update to update a package.

That Homebrew npm caveat was removed after the issue with npm update -g was fixed.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
-1

npm comes bundled with node, both part of Node.js install --- no need to install separately

Below are the steps to install Node.js from source (OSX/linux) Issue cmds as yourself NOT root (sudo)

to start fresh remove prior node and npm installs as well as these :

sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm   ~/.npm_ignore
sudo mv ~/tmp    ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore

download source from : http://nodejs.org/download/

cd freshly-downloaded-dir

define environment variable NODE_PATH as the dir for subsequent module installs

export NODE_PARENT=${HOME}/nodejs-v0.10.33
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules

./configure   --prefix=${NODE_PARENT}

make
make install   #  IMPORTANT this is NOT using sudo
               # not wanted since installing into $USER owned $NODE_PARENT

which puts it into dir defined by above --prefix

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

Now put above three export xxx=yyy commands into your ~/.bashrc or some such to persist these environment variable changes

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104
  • Thanks, but what's the relationship with homebrew? – François Romain Nov 21 '14 at 18:31
  • its just a simple source code install, independent of having to use homebrew ... too often I see people getting frustrated with unnecessary permission issues related to sudo / homebrew / attempting to chown entire /usr/local/ ... besides this makes explicit the location of node related directories – Scott Stensland Nov 21 '14 at 19:26
  • ok, but my question is about 1. what is `npm upgrade` (which is not documented)? 2. is it equivalent to `npm install -g npm@latest`? – François Romain Nov 22 '14 at 00:42
  • The point is installing Node.js gives you both node and npm both. No need to install npm directly. The above Caveats notice is coming from source https://github.com/Homebrew/homebrew/blob/master/Library/Formula/node.rb the essence of which are my above commands – Scott Stensland Nov 22 '14 at 01:33
  • the warning from homebrew is not about installing npm separately, but to update it, it uses the `npm ìnstall` command. right? – François Romain Nov 23 '14 at 01:54