Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.

help-wanted
triaged
cli
priority:medium

(Justin Grant) #1

What I Wanted to Do

Install a global package using sudo npm -g on my Mac running NPM 6.5

What Happened Instead

Every global install failed. Errors included many like this:

WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/widest-line'

And finally one like this that stopped the install:

npm WARN enoent ENOENT: no such file or directory, open '/private/tmp/npm-31930-3d7b0f16/unpack-dda66812/node_modules/run-queue/package.json'

npm ERR! path /private/tmp/npm-31930-3d7b0f16/unpack-dda66812/node_modules/run-queue/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/private/tmp/npm-31930-3d7b0f16/unpack-dda66812/node_modules/run-queue/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Reproduction Steps

  1. Install node via downloadable Mac (Mojave 10.14.2) installer: https://nodejs.org/dist/v10.14.2/node-v10.14.2.pkg
  2. sudo npm install -g npm@6.4.1 to downgrade to working NPM
  3. sudo npm i -g serverless
  4. Works fine.
  5. sudo npm install -g npm@latest
  6. sudo npm i -g serverless
  7. FAIL!

Details

Here’s the NPM debug log shown on 6.5 when trying to re-install the serverless package (after it was successfully installed after the 6.4.1 downgrade, per the repro above).
2018-12-14T19_09_42_771Z-debug.log (292.4 KB)

I’m a new user on this forum so can’t post multiple log files, but before I successfully upgraded the serverless package (via downgrade to 6.4.1) I tried to install it earlier and it still failed, but in addition to the eventual error I also got a bunch of warnings like this:

WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/npm-3e479054/node_modules/widest-line'

Let me know if you need the logfile including these warnings and I can email it to you (or can attach here if I can get permission to do it).

BTW, here’s a support thread reporting the same problem: EISDIR: illegal operation on a directory, open

Platform Info

$ npm --versions
{ npm: '6.5.0',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.14.2',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.45',
  zlib: '1.2.11' }

$ node -p process.platform
darwin

EISDIR: illegal operation on a directory, open
(Alexander Hörl) #2

You don’t have to use sudo before npm install -g on mac actually.

Can you install other packages globally besides serverless ?


(Kat Marchán) #3

This might be a node-tar related issue, possibly. Your log doesn’t show any WARNings, though. Can you DM me one that does include this? I’m gonna /cc @isaacs too.


(Justin Grant) #4

@zkat - here’s another file with lots of WARN lines:
2018-12-14T18_55_55_453Z-debug.log (181.3 KB)

In other news, while investigating @AlexanderProd’s suggestion, I uninstalled the serverless package and then upgraded NPM and re-installed serverless it on npm 6.5. That worked! Something about uninstalling and re-installing fixed whatever problem was there. If you want me to recover the previous state to help repro the problem, I can probably pull the files out of Time Machine backups if you tell me what folders (on a Mac) are needed.

@AlexanderProd - Oh, I don’t use many global packages and serverless definitely requires sudo, so I just assumed that all global installs needed sudo. I just tried and other packages worked without sudo! Thanks for the tip.


(Matthew Riddell) #9

I gave myself access to /usr/local/lib/node_modules and then ran npm install forever -g without sudo and it was fine.


(Kat Marchán) #10

I’m deleting any “me too” posts. If you’re not adding any new information, please use the voting feature at the top of this thread instead.


(Manuel Feller) #11

Yes, this is basically a me too, please delete it if it does not help.
This are the settings on my Mac; since I have slightly different versions then the opener I thought it can be useful:

npm --versions
{ npm: ‘6.5.0’,
ares: ‘1.10.1-DEV’,
cldr: ‘32.0’,
http_parser: ‘2.8.0’,
icu: ‘60.1’,
modules: ‘57’,
nghttp2: ‘1.25.0’,
node: ‘8.11.1’,
openssl: ‘1.0.2o’,
tz: ‘2017c’,
unicode: ‘10.0’,
uv: ‘1.19.1’,
v8: ‘6.2.414.50’,
zlib: ‘1.2.11’ }

The package where I discovered this was cordova.

Thanks @MattRiddell, your post is at least a workaround to downgrade without uninstall / install required stuff (since the downgrade of npm by npm command also failed, see below)

The npm downgrade (sudo npm install -g npm@6.4.1) produced many errors like these:

npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-8193-0bf04d38/unpack-f4a62d18/bin/node-gyp-bin’

Seems it is not tied to the global node_modules folder rights, but a more general thing in the unpacker (or somewhere else)…

Final Error Message was

npm ERR! path /private/tmp/npm-8193-0bf04d38/unpack-f4a62d18/node_modules/run-queue/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open ‘/private/tmp/npm-8193-0bf04d38/unpack-f4a62d18/node_modules/run-queue/package.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Detailed log of the downgrade errors is attached too:
NpmDowngradeBug.log (186.7 KB)


(Rick Luna) #12

Same - upgraded to 6.5, and since I am there I cant downgrade via sudo npm install -g npm@6.4.1 as that now also triggers the same EISDIR errors. Seems I am currently looking at a complete reinstall.