Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using n to install node broke NPM #63

Closed
deremer opened this issue Mar 22, 2012 · 33 comments
Closed

Using n to install node broke NPM #63

deremer opened this issue Mar 22, 2012 · 33 comments

Comments

@deremer
Copy link

deremer commented Mar 22, 2012

I've been working on node 4.7 for a long time because that's all Heroku supported, but recently they announced support for other versions, so I was looking to upgrade node. Since I have production code working on 4.7, I need to swap between 4.7 and 6.13.

n seems awesome and I'd love to use it. For running node, it works fine. But something happened when I installed it such that npm no longer works.

If I switch to n 0.4.7 and run 'npm install' for a module I get:

node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '../lib/npm.js'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:348:19)
at /usr/local/lib/node_modules/npm/bin/npm.js:24:11
at Object. (/usr/local/lib/node_modules/npm/bin/npm.js:87:2)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array. (module.js:423:10)

If I switch to n 0.6.13 and run 'npm install' for a module I get:

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: No such module
at Object. (/usr/local/lib/node_modules/npm/lib/utils/config-defs.js:5:21)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (/usr/local/lib/node_modules/npm/lib/utils/ini.js:40:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)

Your help would be most appreciated as I can't seem to figure it out. Thanks!

@tj
Copy link
Owner

tj commented Mar 22, 2012

thanks to the terrible directory structure of *nix we need to just install a bunch more crap. #62

@deremer
Copy link
Author

deremer commented Mar 22, 2012

Reinstalling NPM (curl http://npmjs.org/install.sh | sh) fixed it for v0.6.13, but now I can't install anything in 0.4.7 because of...

Error: npm doesn't work with node v0.4.7
Required: node@0.6 || 0.7 || 0.8
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:67:23
at Object. (/usr/local/lib/node_modules/npm/bin/npm-cli.js:87:2)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at Array.0 (module.js:423:10)
at EventEmitter._tickCallback (node.js:126:26)

How can I run 2 different versions of NPM?

@vjpr
Copy link

vjpr commented Mar 30, 2012

+1

1 similar comment
@alexkwolfe
Copy link

+1

@deremer
Copy link
Author

deremer commented Apr 11, 2012

In case this helps others...

You can still use N to toggle between 0.4.x and 0.6.x, but each time you need to install the right version of NPM. To install an old version of NPM, follow the instructions I wrote here: http://blog.grandelabs.com/post/20069207998/how-to-install-an-old-version-of-npm

Just an interim solution until the awesome guys at visionmedia can fix this. Cheers!

@alexkwolfe
Copy link

It seems like this was working in a past version of n. Is that true? If so, presumably we could just use an old version of n.

@deianvasilev
Copy link

I got also this:

npm --version

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module '../lib/utils/log.js'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at /usr/local/bin/npm:18:11
at Object. (/usr/local/bin/npm:87:2)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)

So I was pushed to use it like this: /usr/local/n/current/bin/npm --version

@ashtuchkin
Copy link

+1. Had to uninstall n.

@ryancole
Copy link

I just finished a fresh install of Ubuntu. My plan was to use n to install my first version of node.js, so that I could start using node version management from the get-go. n worked great to install node.js, but does not seem to configure everything so that it's also friendly with npm. npm just does not work. I am seeing the same error as noted by @deianvasilev two comments up. Here is some output from my system.

ryan@ryan-server:~$ n
/usr/local/bin/node
  ο 0.6.15
    0.7.8
ryan@ryan-server:~$ n -V
0.7.1
ryan@ryan-server:~$ npm

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module '../lib/utils/log.js'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at /usr/local/bin/npm:18:11
    at Object.<anonymous> (/usr/local/bin/npm:87:2)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)

@525c1e21-bd67-4735-ac99-b4b0e5262290

+1 to this issue

and

+1 to @deremer 's temporary fix (which also worked for 0.6.x <-> 0.7.x)

In case this helps others...

You can still use N to toggle between 0.4.x and 0.6.x, but each time you need to install the right version of NPM. To install an old version of NPM, follow the instructions I wrote here: http://blog.grandelabs.com/post/20069207998/how-to-install-an-old-version-of-npm

Just an interim solution until the awesome guys at visionmedia can fix this. Cheers!

@sveisvei
Copy link

xmppo/node-expat#16 Having similar issues

@rauchg
Copy link

rauchg commented May 23, 2012

+1

@sveisvei
Copy link

I had to remove ~/.npm and ~/.npmrc to get this working again, dunno which of the folders made it work.

@akumpf
Copy link

akumpf commented Jun 1, 2012

ok, so had the same issue: looks like the problem is that /usr/local/bin/npm is populated with the npm file instead of a symbolic link to the current npm version (/usr/local/n/current/bin/npm).

I'm sure there's a more robust fix -- @visionmedia am I missing something here? would be great to update n to take care of this pesky npm issue :)

cheers,
Adam

@tj
Copy link
Owner

tj commented Jun 1, 2012

as long as we copy everything from the build it should just work

@akumpf
Copy link

akumpf commented Jun 1, 2012

Looking in /usr/local/bin/npm you can see it references a relative directory ("../lib/ ... "). I think that's what's breaking.

How should we resolve it? Is there a down-side to using symbolic links to the current version instead of copying?

@tj
Copy link
Owner

tj commented Jun 1, 2012

symlinks should be fine, i just went with copying originally because it was the first thing i wrote and the time it took was negligible so i didn't bother with symlinks :D

@TedAvery
Copy link

+1 :(

@dwradcliffe
Copy link

+1

My temp fix:

cd /usr/local/bin
mv npm npm.old
ln -s /usr/local/n/current/bin/npm .

@rauchg
Copy link

rauchg commented Jun 21, 2012

+1

1 similar comment
@tj
Copy link
Owner

tj commented Jun 21, 2012

+1

@guybrush
Copy link
Contributor

mkdir ~/local
export PATH=~/local/bin:"$PATH"
curl http://npmjs.org/install.sh | npm_config_prefix=~/local sh

now i can do:

patrick@ilvy ~ $ which npm
/home/patrick/bin/npm
patrick@ilvy ~ $ npm -v
1.1.32
patrick@ilvy ~ $ n -V
0.7.2
patrick@ilvy ~ $ node -v
v0.6.19
patrick@ilvy ~ $ sudo n 0.8.0
/usr/local/bin/node
patrick@ilvy ~ $ node -v
v0.8.0
patrick@ilvy ~ $ which npm
/home/patrick/bin/npm
patrick@ilvy ~ $ npm -v
1.1.32
patrick@ilvy ~ $ sudo n 0.6.19
/usr/local/bin/node
patrick@ilvy ~ $ node -v
v0.6.19
patrick@ilvy ~ $ which npm
/home/patrick/bin/npm
patrick@ilvy ~ $ npm -v
1.1.32

@guybrush
Copy link
Contributor

oh.. with sudo npm it still sucks this way :/

@samccone
Copy link

+1

going from 0.8.0 to 0.6.19

module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module '../lib/utils/log.js'

@tj
Copy link
Owner

tj commented Jun 27, 2012

+1

1 similar comment
@rauchg
Copy link

rauchg commented Jun 27, 2012

+1

@samccone
Copy link

@visionmedia are you trolling me?

@guybrush
Copy link
Contributor

you can do n 0.8.0 --without-npm then it will only install node without npm

if you have already installed a node with npm (via n), just remove $n_prefix/versions/<node-version>/bin/npm

this way n will not destroy npm, but one has to install npm manually (which i prefer anyways)

we could hardcode it (https://github.com/visionmedia/n/blob/master/bin/n#L196), since most users of n will use a custom installed npm anyway?

actually i think the best solution would be to hardcode it into node :P

@ghost
Copy link

ghost commented Jul 7, 2012

In your .bashrc if your ok with relying on what ever n is doing
alias npm="n npm node -v"

@BenJam
Copy link

BenJam commented Jan 18, 2013

+1 for n having a 'meh' attitude to node_modules, great idea but poorly executed.

@tj
Copy link
Owner

tj commented Jan 18, 2013

with all the pullrequests that have slowly kinda messed things up this could use a rewrite entirely, plus now we have binaries to install instead

@tj tj closed this as completed Jan 18, 2013
@jessekinsman
Copy link

I agree with this issue it kind of makes this module useless

@noorzaie
Copy link

2+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests