Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

npm upgrade leads to Error: ENOENT, open '/Users/<username>/null' #5613

Closed
OverZealous opened this issue Jul 3, 2014 · 16 comments
Closed

npm upgrade leads to Error: ENOENT, open '/Users/<username>/null' #5613

OverZealous opened this issue Jul 3, 2014 · 16 comments
Labels

Comments

@OverZealous
Copy link

SOLUTION FOUND: See @alkama's solution below!


I'm getting this error log no matter what command I run, no matter what directory I start NPM in.

0 info it worked if it ends with ok
1 verbose cli [ '/opt/local/bin/node', '/opt/local/bin/npm' ]
2 info using npm@1.4.20
3 info using node@v0.10.29
4 error Error: ENOENT, open '/Users/phil/null'
5 error If you need help, you may report this *entire* log,
5 error including the npm and node versions, at:
5 error     <http://github.com/npm/npm/issues>
6 error System Darwin 13.3.0
7 error command "/opt/local/bin/node" "/opt/local/bin/npm"
8 error cwd /Users/phil
9 error node -v v0.10.29
10 error npm -v 1.4.20
11 error path /Users/phil/null
12 error code ENOENT
13 error errno 34
14 verbose exit [ 34, true ]

The actual path in the error is simply the CWD, followed by /null.

All I've changed was an upgrade to npm version from 1.4.16_0 to 1.4.20_0 via MacPorts. This is on OS X v10.9.4, MacPorts v2.3.1, Node v0.10.29.

The only command that doesn't fail is npm -v. Even npm -h fails with the same error message.

I've tried uninstalling and reinstalling NPM, but I get the same bizarre error. I tried to step down to 1.4.19, same error. Finally, downgrading back to 1.4.16 removed the issue completely.

Note: I have my global packages installed in a subfolder under my user account, via .npmrc - prefix, so everything except npm itself is installed under my account.

I'd be happy to help debug this, I just have no idea how to figure out where the error is happening.

@alkama
Copy link

alkama commented Jul 3, 2014

I can confirm this as I'm having the very same issue (same version numbers too).

I'll also fallback to 1.4.16_0

@PhantomRay
Copy link

I confirm that I have same issue on OS X 10.9.4 after upgrading to 1.4.20 using macports.

npm cache clean or remove ~/.npm didn't work.

Rolled back to 1.4.16

@drjokepu
Copy link

drjokepu commented Jul 4, 2014

I'm getting the same error with npm 1.4.20 from MacPorts on OS X 10.9.4:

0 info it worked if it ends with ok
1 verbose cli [ '/opt/local/bin/node', '/opt/local/bin/npm' ]
2 info using npm@1.4.20
3 info using node@v0.10.29
4 error Error: ENOENT, open '/Users/tamas/null'
5 error If you need help, you may report this *entire* log,
5 error including the npm and node versions, at:
5 error     <http://github.com/npm/npm/issues>
6 error System Darwin 13.3.0
7 error command "/opt/local/bin/node" "/opt/local/bin/npm"
8 error cwd /Users/tamas
9 error node -v v0.10.29
10 error npm -v 1.4.20
11 error path /Users/tamas/null
12 error code ENOENT
13 error errno 34
14 verbose exit [ 34, true ]

@BurningDog
Copy link

Same error for me with npm 1.4.20 on Macports on OS X 10.6.8.

@emirotin
Copy link

emirotin commented Jul 7, 2014

same for me, macports and osx 10.9.4

@othiym23
Copy link
Contributor

othiym23 commented Jul 7, 2014

Hey guys, this is clearly a problem, and I haven't had time to dig into it yet (nor do I have MacPorts installed). Since it seems to be localized to MacPorts, is there a chance that one or more of you could raise this issue with MacPorts so they can start taking a look at it too?

@emirotin
Copy link

emirotin commented Jul 7, 2014

Created here https://trac.macports.org/ticket/44271

@othiym23
Copy link
Contributor

othiym23 commented Jul 8, 2014

Thanks, @emirotin!

@alkama
Copy link

alkama commented Jul 13, 2014

* solution at the bottom*

Well, I tried to trace the issue and found something strange happening with the submodule "npmconf" that is a dependancy of npm along with its own submodule "nopt".

In npmconf:

In the main file npmconf/npmconf.js of this module, line 175, there is a:

function afterExtras(er) {
...
    validate(conf)

    var cafile = conf.get('cafile') // <-- Problem here (should be null, and it's "/CWD/null"

    if (cafile) {
        return conf.loadCAFile(cafile, finalize)
    }
...

For infos, it seems the "conf" object gets messed up during the validate(conf) call.

When I inspect that function, I get

function validate (cl) {
...
  nopt.clean(cl.root, configDefs.types) // <-- Messed up from null to a "/CWD/null" during this call
}

Digging into nopt:

Digging deeper. I finally found a problem with the module "nopt"
In /nopt/lib/nopt.js line 127

function validatePath (data, k, val) {
  if (val === true) return false
  data[k] = path.resolve(String(val)) // <-- EWW ! in our case, val is null !
  return true
}

So here the null val is converted to "null" and resolved as a path...
And path.resolve('null') indeed gives /CWD/null

Solution:

The bug in nopt has already been corrected !
npm/nopt@5a73af1#diff-59b8d3fa564f3d398f93362b1180e6ba

We will have to wait for npmconf to update its dependancy (to 3.0.1 at least).

Strange thing is that npmconf depends on "nopt": "~3.0.1"
but it actually gets a nopt that is "version": "2.2.0", installed in its node_modules...

Meanwhile, a temporary solution is to edit:

/opt/local/lib/node_modules/npm/node_modules/npmconf/node_modules/nopt/lib/nopt.js

At line 127:

function validatePath (data, k, val) {
  if (val === true) return false
  if (val === null) return true // <-- ADD THIS LINE !
  data[k] = path.resolve(String(val))
  return true
}

Voila.

@alkama
Copy link

alkama commented Jul 15, 2014

Clean solution:

sudo port uninstall npm
sudo rm -rf /opt/local/lib/node_modules/npm/
sudo port install npm

Damn, spent all this time looking for a bug when it was just a "old file and directory structure" colliding with the new install...

Long story short, when upgrading (or uninstall and reinstall), some node_modules subdirectories of npm are not cleaned up and mix and mash with the new directory structure.
We end up with old dependancies in places where they should have been removed.

Proof (for the one having the problem that still haven't applied the solution):
Check /opt/local/lib/node_modules/npm/node_modules/npmconf/node_modules/.
If it still contains the nopts directory, it's a relict. It should not be there anymore according to the source file archive that the port targets: http://registry.npmjs.org/npm/-/npm-1.4.20.tgz

@OverZealous
Copy link
Author

I can confirm that @alkama solution worked for me. The bug is definitely related to the garbage directories. Ack!

@OverZealous
Copy link
Author

@alkama Do you want to mention this solution over on the MacPorts bug report?

@PhantomRay
Copy link

Thanks @Alkma, that works.

@TravelingTechGuy
Copy link

Mac OSX 10.7.5, NPM 1.4.20 - can confirm @alkama 's solution worked. Thanks!

@mst-appear
Copy link

I get the same issue on Ubuntu Linux:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install' ]
2 info using npm@1.4.21
3 info using node@v0.10.30
4 verbose node symlink /usr/bin/node
5 error Error: ENOENT, open '/home/mst/Dev/site-diary/frontend/null'
6 error If you need help, you may report this entire log,
6 error including the npm and node versions, at:
6 error http://github.com/npm/npm/issues
7 error System Linux 3.2.0-67-generic-pae
8 error command "/usr/bin/node" "/usr/bin/npm" "install"
9 error cwd /home/mst/Dev/site-diary/frontend
10 error node -v v0.10.30
11 error npm -v 1.4.21
12 error path /home/mst/Dev/site-diary/frontend/null
13 error code ENOENT
14 error errno 34
15 verbose exit [ 34, true ]

I have this package installed:
ii nodejs 0.10.30-1chl1~precise1 Node.js event-based server-side javascript engine

@nidelson
Copy link

Thanks @Alkma, that works.
Mac OS X 10.10 (14A299l), NPM 1.4.23 working fine.

@othiym23 othiym23 changed the title NPM Upgrade leads to Error: ENOENT, open '/Users/<username>/null' npm upgrade leads to Error: ENOENT, open '/Users/<username>/null' Sep 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

10 participants