0

I have installed node via nvm. I am trying to update npm. Current version:

npm -v
1.4.28
$ which npm
/Users/per/.nvm/v0.10.33/bin/npm
$ node -v
v0.10.33

Installing npm:

cd
curl -L https://npmjs.org/install.sh | sh

/Users/per/.node/bin/npm -> /Users/per/.node/lib/node_modules/npm/bin/npm-cli.js
npm@2.1.11 /Users/per/.node/lib/node_modules/npm
It worked

Checking npm version after install:

npm -v
1.4.28
$ which npm
/Users/per/.nvm/v0.10.33/bin/npm

How do I get npm to install itself in the nvm directory?

EDIT =================================

The root cause for wanting to replace npm with a new version is that I get a load of error messages when using it. One of the messages say:

imagemin@3.1.0: wanted: {"node":">=0.10.0","npm":">=2.1.5"} (current:{"node":"0.10.33","npm":"1.4.28"})

So that one seems to explicitly ask for a newer version of npm. The others are mostly about "Unmet dependencies". There are loads of them, but here is one example:

npm WARN unmet dependency /Users/per/.node/lib/node_modules/generator-angular/node_modules/yeoman-generator/node_modules/request/node_modules/form-data requires async@'~0.9.0' but will load
Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
  • I'm curious, is there a specific reason why you need to update npm? – mscdex Dec 05 '14 at 14:55
  • I think it's become corrupt. I get a load of error messages when I try to install stuff. 'npm cache clean' does not help, so I'm trying to replace the old version. – Per Quested Aronsson Dec 05 '14 at 14:58
  • What are the error messages? – mscdex Dec 05 '14 at 14:59
  • I've updated the question with more info regarding the error messages. – Per Quested Aronsson Dec 05 '14 at 15:15
  • 1
    That doesn't look like npm is corrupt to me. `imagemin`'s npm version requirement is way too high. My guess is that it's explicitly requiring an npm version because it uses a "newer" dependency version symbol (`^` IIRC) which is only supported in "newer" npm versions (although "newer" here is actually quite old by now and it's definitely supported by the npm shipped with node v0.10.33). – mscdex Dec 05 '14 at 15:23
  • I'm not sure about the `async` module error, the line seems to be missing additional text. – mscdex Dec 05 '14 at 15:24

2 Answers2

0

In Win 7 Try this: - install node.js from website. (0.10.33 version) (in my case destination folder was C:\Program Files\nodejs)

  • npm was installed automatically (i guess), npm verstion - 1.4.28, and plased in C:\Program Files\nodejs\node_modules\npm

  • after installing(updating) new npm (npm install npm -g), destination folder was C:\Users\username\AppData\Roaming\npm\node_modules\npm

Copy all from folder2 to folder1. and check verstion;

0

This is what finally worked for me: It seemed like sass and compass had not been installed properly. I started investigating why and stumbled across this solution.

I fairly recently upgraded to OSX Mavericks, which seems to have broken the possibility to install rubygems using native extensions. By running the commands below I first reinstated functional command line tools.

$ sudo xcode-select --install
$ xcode-select --print-path

Furthermore, I had to install the gem using the following flag:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install <gemName>

After having done this, everything started working as it should. Running npm install no longer produced a load of error messages, so there was no need to replace the npm used with nvm.

References:

Community
  • 1
  • 1
Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76