npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

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

Perhaps safer:
sudo chown -R $(whoami) /usr/local/lib/node_modules/
rather than
sudo chown -R $(whoami) /usr/local/lib
(I didn’t need to change permissions on /usr/local/bin, but admittedly my machine is in an odd state.)


I’m having the same exact issue, I updated to npm 6.5 and now can’t globally install a package.


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


Tnks! I can solved my fix problem with gatsby.js


Hi @godmar

You are using “global” in the sense of a system wide install on a (usually) multi-user system.

I am using “global” in the usual npm sense, which is referring to the single shared location for installs outside of a package. This may be in a system folder, but is also commonly in the users home folder.

The two concepts do overlap when the npm global install is to a system location!

(I was aware my chown instructions were not conventional for a multi-user system, and qualified Assuming this is your personal computer. Most readers here are probably using single user systems, whether desktop or VM or docker container. There is some related “global” discussion in Correctness of "resolving EACCES Permissions errors when installing packages globally")


Same for me, Mac OS Mojave 10.14.1
npm 6.5.0


like a charm! :grinning:


@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.


checked the permissions of these folders mentioned; problem fixed by following steps. Thanks a lot.


@umbeb

I am not sure about error in tmp location. You could try the downgrade command with an explicit tmp directory:

mkdir /tmp/delete_me
sudo npm_config_tmp=/tmp/delete_me npm install -g npm@6.4.1
sudo rm -rf /tmp/delete_me


Hi @shadowspawn! I have the same issue of @asdad2. I’ve just launched npm -g prefix and the result it’s exactly “/usr/local”.
If I try to downgrade with “sudo npm install -g npm@6.4.1”, I have a long list of error on many files. Below some of this error:

npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/bin/node-gyp-bin’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/changelogs’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/doc/cli’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/doc/files’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/doc/misc’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/doc/spec’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/html/doc/cli’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/tmp/npm-19865-334adb21/unpack-3b041077/html/doc/files’

Do you have any idea?
Thanks!!


BTW, this solution from @shadowspawn worked perfectly on my Mac w/Mojave to enable global installs of NPM and other packages without requiring sudo. It even works for the serverless package which kicked off this thread. Thanks John!


(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


I am using latest mac and npm:

Unhandled rejection Error: EISDIR: illegal operation on a directory, open ‘/Users/peter/.npm/_cacache/index-v5/23/9a’


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


Me too had the same problem right now with NPM v 6.7 and Mac OS Mojave. I’ve downgraded to NPM v 6.4.1 (thanks to Node 10.15.1 installer because it was impossibile through NPM itself) and now it works again.
It give me both “EISDIR” (nothing changed changing owner or deleting this 6 folders that randomly give me that warning) and “cb() never called” just trying to install jest globally ( both “npm intall -g jest” and “sudo npm install -g jest”).


Update for developers: @godmar tracked down possible source of problem: https://github.com/zkat/pacote/issues/174


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

Can you install other packages globally besides serverless ?


I think I’m having the same issue on Ubuntu. I originally reported it against the Node repository here:

I’m running npm 6.7.0.

I tried downgrading all the way to 6.3.0, but it’s not helping. I still get this:

ole@mki:~/SuperflyCSS/cli$ npm --version
6.3.0
ole@mki:~/SuperflyCSS/cli$ npm i -g
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (../../../../../SuperflyCSS/cli/node_modules/fsevents):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/fsevents-a1705062/node_modules/abbrev' -> '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/abbrev-0e9f4c13'

npm ERR! path /home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@superflycss/cli-5549c074/node_modules/@babel/code-frame
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@superflycss/cli-5549c074/node_modules/@babel/code-frame' -> '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@babel/code-frame-78217d7a'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ole/.npm/_logs/2019-02-07T18_06_44_825Z-debug.log
ole@mki:~/SuperflyCSS/cli$ 

Also tried upgrading to latest version of node. Same result.


John,

your work-arounds (all 3 of them) defeat the entire idea of a “global” install, which is that it persists even if your user is removed from the system.


Some for me. This solution worked like charm – and saved my evening. :) Thanks a lot, John!


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.


Thank you for clarifying. You are correct regarding the sense of global.

This sense of global (npm’s shared location is in a systems folder) is what you get if you follow node.js’s own instructions for Debian as outlined here.

Or read the instructions here.


Changing the ownership of files and then avoiding use of sudo is a possible work-around for EISDIR with global installs using sudo. Assuming this is your personal computer, and installing to default location on Mac:

sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin

Then try your command again without sudo. e.g.

npm install -g npm@latest

Note also, you can vote for this issue to give it more weight:


I’m on macOS Mojave Version 10.14.2
Solution from @shadowspawn doesn’t work for me and also I get the same error trying to downgrade it as well with sudo npm install -g npm@6.4.1
Please I need a fix


I am linking to this topic a lot, so I’ll add a general note too.

It is good practice to avoid using sudo with npm, but this does require a little extra work. Your three main options are:

  1. change the ownership of the global install location
  2. change the location of the global install location to somewhere you own, by changing where you install node and npm (node version managers typically do this)
  3. change the location of the global install location to somewhere you own, by changing npm configuration


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.


I solved it on Ubuntu by upgrading node to v11.9.0 using NVM and using npm 6.7.0.


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.


@asdad2

  1. The instructions I gave assume you are installing global modules to /usr/local/. Is that the case for you?
$ npm -g prefix
/usr/local
  1. What error are you getting? (What path is mentioned?)


Can confirm. This worked for me. Using WebStorm console, macOS Mojave.


Although pacote 174 is one of the defects that needs fixing before npm can be used reliably with sudo, the issue here (EISDIR affecting only MacOS users) is more likely due to a faulty bug fix introduced in chownr as discussed here.


Also having the same issue, on Mac High Sierra. I’m not able to downgrade to 6.4.1, because I get the EISDIR warnings. Log attached.
2018-12-26T21_47_14_049Z-debug.log (187.3 KB)


My issues were also with /tmp but after using the chown commands you specified it all worked. I assume (have not investigated further) that it may be something to do with copying from /tmp to ~/.npm or such.


Thanks John.
Your solution worked well.


升级npm,导致node和npm不匹配,你应该重新去官网下载安装node再升级npm


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)


Same issue for me.

npm: 6.5.0
macOs Mojave 10.14.2

2018-12-29T10_50_01_145Z-debug.log (101,2 KB)