npm Community Forum (Archive)

The npm community forum has been discontinued.

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

NPM v6.9.0 will not update on High Sierra

What I Wanted to Do

Upgrade npm to its latest version. On my MacOS High Sierra I ran “sudo npm install -g n” hoping it would run the upgrade.

What Happened Instead

$ sudo npm install -g n
npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/n-3eb27508/bin’
Unhandled rejection Error: EISDIR: illegal operation on a directory, open ‘/Users/zharvey/.npm/_cacache/content-v2/sha512/9b/14’

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/zharvey/.npm/_logs/2019-06-14T12_42_09_335Z-debug.log

I checked and “/Users/zharvey/.npm/_logs/2019-06-14T12_42_09_335Z-debug.log” is an empty log file!

Reproduction Steps

See above just run “sudo npm install -g n” on a High Sierra.


This is my personal laptop and I have full access to everything on it.

Platform Info

Mac OS High Sierra 10.13.6

$ npm --versions
{ npm: '6.9.0',
  ares: '1.14.0',
  cldr: '33.0',
  http_parser: '2.8.0',
  icu: '61.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.29.0',
  node: '10.4.0',
  openssl: '1.1.0h',
  tz: '2018c',
  unicode: '10.0',
  uv: '1.20.3',
  v8: '',
  zlib: '1.2.11' }

$ node -p process.platform

Try this. In /usr/lib/node_modules/npm/node_modules/chownr/chownr.js change:

/* istanbul ignore next */
const LCHOWN = fs.lchown ? 'lchown' : 'chown'
/* istanbul ignore next */
const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'


/* istanbul ignore next */
const LCHOWN = 'chown'
/* istanbul ignore next */
const LCHOWNSYNC = 'chownSync'

Thanks @godmar, but I’m on a Mac and that directory doesn’t exist:

$ ls -al /usr/lib/node_modules/npm/node_modules/chownr/
ls: /usr/lib/node_modules/npm/node_modules/chownr/: No such file or directory
$ sudo ls -al /usr/lib/node_modules/npm/node_modules/chownr/
ls: /usr/lib/node_modules/npm/node_modules/chownr/: No such file or directory

Any ideas?

Does locate work? Try locate chownr.js.

I think your node is probably under /usr/local, so instead of /usr/lib/node_modules/npm/node_modules/chownr/chownr.js it would be /usr/local/lib/node_modules/npm/node_modules/chownr/chownr.js

Perfect, yes that is the correct location on my Mac, thanks! So I made the changes you suggested in chownr.js and then re-ran sudo npm install -g n and got this new error:

$ sudo npm install -g n
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/n-3eb27508/bin'
npm ERR! path /usr/local/lib/node_modules/n/bin/n
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/n/bin/n'
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!     /Users/zharvey/.npm/_logs/2019-06-14T13_55_50_358Z-debug.log

And the contents of that 2019-06-14T13_55_50_358Z-debug.log log file are:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/10.4.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'n' ]
2 info using npm@6.9.0
3 info using node@v10.4.0
4 verbose npm-session 049d59e979f7032a
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 16ms (from cache)
8 silly pacote tag manifest for n@latest fetched in 27ms
9 timing stage:loadCurrentTree Completed in 62ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule n@4.1.0 checking installable status
17 silly removeObsoleteDep removing n@4.1.0 from the tree as its been replaced by a newer version or is no longer required
18 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 4ms
19 timing stage:loadIdealTree Completed in 7ms
20 silly currentTree lib
20 silly currentTree └── n@4.1.0
21 silly idealTree lib
21 silly idealTree └── n@4.1.0
22 silly install generateActionsToTake
23 timing stage:generateActionsToTake Completed in 4ms
24 silly diffTrees action count 1
25 silly diffTrees update n@4.1.0
26 silly decomposeActions action count 10
27 silly decomposeActions unbuild n@4.1.0
28 silly decomposeActions remove n@4.1.0
29 silly decomposeActions fetch n@4.1.0
30 silly decomposeActions extract n@4.1.0
31 silly decomposeActions preinstall n@4.1.0
32 silly decomposeActions build n@4.1.0
33 silly decomposeActions install n@4.1.0
34 silly decomposeActions postinstall n@4.1.0
35 silly decomposeActions finalize n@4.1.0
36 silly decomposeActions refresh-package-json n@4.1.0
37 silly install executeActions
38 silly doSerial global-install 10
39 verbose correctMkdir /Users/zharvey/.npm/_locks correctMkdir not in flight; initializing
40 verbose lock using /Users/zharvey/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
41 silly doParallel extract 1
42 silly extract n@4.1.0
43 silly tarball trying n@latest by hash: sha512-mxQCssMwxWKj5TIVfDJZgFpqs9sH02Y2QfMOx1g2M1c0SCTBOa6HDOb5KZvpY4SwhzpLXMrPFP+OzCc75FJK2g==
44 warn tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/n-3eb27508/bin'
45 silly extract n@latest extracted to /usr/local/lib/node_modules/.staging/n-3eb27508 (19ms)
46 timing action:extract Completed in 24ms
47 silly doReverseSerial unbuild 10
48 silly unbuild n@4.1.0
49 info lifecycle n@4.1.0~preuninstall: n@4.1.0
50 info lifecycle n@4.1.0~uninstall: n@4.1.0
51 verbose unbuild rmStuff n@4.1.0 from /usr/local/lib/node_modules
52 silly isEverInside /usr/local/bin/n is not inside /usr/local/lib/node_modules/n
53 silly gentlyRm parent.path = /usr/local/lib/node_modules/n
54 silly gentlyRm parent.managed = /usr/local/lib/node_modules/n is in /usr/local
55 silly gentlyRm target.path =  /usr/local/bin/n
56 silly gentlyRm target.symlink = ../lib/node_modules/n/bin/n
57 silly gentlyRm target.managed = /usr/local/bin/n is in /usr/local
58 silly gentlyRm target.inParent =  { target: '/usr/local/lib/node_modules/n/bin/n',
58 silly gentlyRm   path: '/usr/local/lib/node_modules/n' }
59 info lifecycle n@4.1.0~postuninstall: n@4.1.0
60 timing action:unbuild Completed in 10ms
61 silly doSerial remove 10
62 silly remove /usr/local/lib/node_modules/n
63 timing action:remove Completed in 4ms
64 silly doSerial move 10
65 silly doSerial finalize 10
66 silly finalize /usr/local/lib/node_modules/n
67 timing action:finalize Completed in 1ms
68 silly doParallel refresh-package-json 1
69 silly refresh-package-json /usr/local/lib/node_modules/n
70 timing action:refresh-package-json Completed in 5ms
71 silly doParallel preinstall 1
72 silly preinstall n@4.1.0
73 info lifecycle n@4.1.0~preinstall: n@4.1.0
74 timing action:preinstall Completed in 1ms
75 silly doSerial build 10
76 silly build n@4.1.0
77 info linkStuff n@4.1.0
78 silly linkStuff n@4.1.0 has /usr/local/lib/node_modules as its parent node_modules
79 silly linkStuff n@4.1.0 is part of a global install
80 silly linkStuff n@4.1.0 is installed into a global node_modules
81 silly linkStuff n@4.1.0 is installed into the top-level global node_modules
82 verbose linkBins [ { n: './bin/n' }, '/usr/local/bin', true ]
83 timing action:build Completed in 2ms
84 verbose unlock done using /Users/zharvey/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
85 timing stage:rollbackFailedOptional Completed in 2ms
86 timing stage:runTopLevelLifecycles Completed in 130ms
87 verbose stack Error: ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/n/bin/n'
88 verbose cwd /Users/zharvey/workspace/dillon/ecommerce-integration
89 verbose Darwin 17.7.0
90 verbose argv "/usr/local/Cellar/node/10.4.0/bin/node" "/usr/local/bin/npm" "install" "-g" "n"
91 verbose node v10.4.0
92 verbose npm  v6.9.0
93 error path /usr/local/lib/node_modules/n/bin/n
94 error code ENOENT
95 error errno -2
96 error syscall chmod
97 error enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/n/bin/n'
98 error enoent This is related to npm not being able to find a file.
99 verbose exit [ -2, true ]

Can you change /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/chownr/chownr.js likewise? I’m trying to test chownr #20 btw

Hey it worked!

$ sudo npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@4.1.0
updated 1 package in 0.132s
$ npm -v
$ node -v

So the sudo npm install -g n ran successfully (I think!). However I’m still showing that I’m on node v10.4.0, and what I’m really trying to do is upgrade that to v10.9.0+ because the Angular docs say that the system requirements are 10.9.0+. Any ideas how I can get from 10.4.0 -> 10.9.0+? Thanks again enormously for all your help so far!

n is a node version manager. Type n for instructions.

Beautiful! thank you so much for you quick + helpful responses here! You changed me from being frustrated with NPM to being a big fan :-)

Thanks @godmar and @zharvey for doing some detailed investigation!