Gatsby Won't Build Site Due to NPM error

What I Wanted to Do

Trying to build a starter site with gatsby.js

What Happened Instead

Threw an error and wouldn’t finish build
➜ ~ gatsby new hello-world
info Creating new site from git:

Cloning into ‘hello-world’…
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 677 (delta 20), reused 24 (delta 12), pack-reused 645
Receiving objects: 100% (677/677), 2.24 MiB | 0 bytes/s, done.
success Created starter directory layout
info Installing packages…

Unhandled rejection Error: EACCES: permission denied, open ‘/Users/xxxx/.npm/_cacache/index-v5/9a/10/33e796ac306baba1c40df7c2947f3f1bd4ab60dd95fc46163a5c5780e2cc’

Unhandled rejection Error: EACCES: permission denied, open ‘/Users/xxxxxx/.npm/_cacache/index-v5/31/20/8adeae80412ed6738e57f534ae2f73538a68ea1aec4c53ec4d639caa500b’

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:
error Command failed: npm install

Error: Command failed: npm install

  • index.js:236 Promise.all.then.arr

  • next_tick.js:68 process._tickCallback

Reproduction Steps

installed and updated all dependencies: npm, nodejs, brew, xcode, git and gatsby
Ran “gatsby new”


Mac High Sierra Version 10.13.6

Platform Info

$ npm --versions
{ npm: '6.9.0',
  ares: '1.14.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.33.0',
  node: '10.10.0',
  openssl: '1.1.0i',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.0',
  v8: '',
  zlib: '1.2.11' }
$ node -p process.platform

Hi @SVGE! 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 running gatsby 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.

1 Like

Thank you John! This fixed it :) Cheers! I was able to deploy and serve after running that command.

1 Like

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