Error installing gatsby-plugin-offline

Following gatsbyjs tutorial, at https://www.gatsbyjs.org/tutorial/part-eight/
Gatsby CLI version: 2.7.7
Gatsby version: 2.11.7
NPM version: 6.9.2
Nodejs version: 10.16.0
macos 10.14.5

Unhandled rejection Error: EACCES: permission denied, open ā€˜/Users/shunyun/.npm/_cacache/index-v5/e1/e1/54432ebdd789ede817eebebf49732b4f1ffdef8659b789db14866e256d7dā€™
at fixOwner.mkdirfix.then (/usr/local/lib/node_modules/npm/node_modules/cacache/lib/entry-index.js:62:12)
at /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:48:26
at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:285:20
From previous event:
at Object.insert (/usr/local/lib/node_modules/npm/node_modules/cacache/lib/entry-index.js:53:5)
at write.then.res (/usr/local/lib/node_modules/npm/node_modules/cacache/put.js:30:18)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
From previous event:
at putData (/usr/local/lib/node_modules/npm/node_modules/cacache/put.js:29:35)
at Object.x.put (/usr/local/lib/node_modules/npm/node_modules/cacache/locales/en.js:31:37)
at WriteStream.done [as _flush] (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/cache.js:156:21)
at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:36:35)
at doWrite (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at WriteStream.end (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:45:41)
at WriteStream.end (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:42:47)
at WriteStream.done [as _flush] (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/cache.js:173:45)
at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:36:35)
at doWrite (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at WriteStream.end (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:45:41)
at WriteStream.end (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:42:47)
at WriteStream.done [as _flush] (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/cache.js:186:19)
at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/index.js:36:35)
at doWrite (/usr/local/lib/node_modules/npm/node_modules/flush-write-stream/node_modules/readable-stream/lib/_stream_writable.js:428:64)

npm ERR! cb() never called!

There is an open issue with installing global packages using sudo leaving behind files with the wrong ownership.

The short version is run this to fix the ownership, then try your install again:

sudo chown -R $(whoami) ~/.npm

The long version and canonical bug is: Global installs (sudo npm i -g) fail on Mac after 6.5 upgrade. Works fine after 6.4.1 downgrade.

John, thanks for the quick help! That did the trick.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.