Ghost install local fails in MacOS

I have been unable to install ghost locally on MacOS. I was able to install via ghost-cli about a year ago, and are am now trying to get a fresh, current install of ghost. Here are my system versions:

❯ ghost --version
Running in development mode
Ghost-CLI version: 1.24.2

❯ node --version
v18.17.1

❯ npm --version
9.6.7

❯ python3 --version
Python 3.9.6

❯ yarn --version
1.22.19

Ghost Doctor can be run in an old install that is running Ghost 5.33.0:

❯ ghost doctor
✔ Checking system Node.js version - found v18.17.1
✔ Checking current folder permissions
✔ Validating config
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space

Here is the full error:

❯ ghost install local

Running in development mode

✔ Checking system Node.js version - found v18.17.1
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking free space
✔ Checking for latest Ghost version
✔ Setting up install directory
✖ Downloading and installing Ghost v5.61.1
A ProcessError occurred.

Message: Command failed: yarn install --no-emoji --no-progress
warning ../../../package.json: No license field
warning ghost@5.61.1: The engine "cli" appears to be invalid.
warning Resolution field "@elastic/elasticsearch@8.5.0" is incompatible with requested version "@elastic/elasticsearch@8.6.0"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@^2.29.1"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.21"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.25"
warning Resolution field "@tryghost/logging@2.4.4" is incompatible with requested version "@tryghost/logging@2.4.5"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@2.29.1"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@^2.27.0"
warning Resolution field "moment-timezone@0.5.23" is incompatible with requested version "moment-timezone@^0.5.31"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@2.29.4"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.25"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@2.29.4"
warning Resolution field "moment-timezone@0.5.23" is incompatible with requested version "moment-timezone@0.5.34"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.25"
warning Resolution field "@tryghost/logging@2.4.4" is incompatible with requested version "@tryghost/logging@2.4.5"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.21"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@2.29.1"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@2.29.3"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@^1.2.26"
warning Resolution field "moment-timezone@0.5.23" is incompatible with requested version "moment-timezone@^0.5.33"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@^1.2.26"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@^1.2.26"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@^2.27.0"
warning Resolution field "moment-timezone@0.5.23" is incompatible with requested version "moment-timezone@^0.5.31"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@^1.2.26"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@2.27.0"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.25"
warning Resolution field "@tryghost/logging@2.4.4" is incompatible with requested version "@tryghost/logging@2.4.5"
warning Resolution field "@tryghost/logging@2.4.4" is incompatible with requested version "@tryghost/logging@^2.4.5"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@1.2.25"
warning Resolution field "@tryghost/logging@2.4.4" is incompatible with requested version "@tryghost/logging@2.4.5"
warning Resolution field "@tryghost/errors@1.2.24" is incompatible with requested version "@tryghost/errors@^1.2.26"
warning Resolution field "moment@2.24.0" is incompatible with requested version "moment@^2.29.1"
warning "@tryghost/kg-lexical-html-renderer > @lexical/rich-text@0.12.0" has unmet peer dependency "@lexical/selection@0.12.0".
warning "@tryghost/kg-lexical-html-renderer > @lexical/rich-text@0.12.0" has unmet peer dependency "@lexical/utils@0.12.0".
warning " > bookshelf@1.2.0" has incorrect peer dependency "knex@>=0.15.0 <0.22.0".
error /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2: Command failed.
Exit code: 7
Command: install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR --skip-path-var RE2_DOWNLOAD_SKIP_PATH --skip-ver-var RE2_DOWNLOAD_SKIP_VER || npm run rebuild
Arguments:
Directory: /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2
Output:
Trying https://github.com/uhop/node-re2/releases/download/1.20.3/darwin-x64-108.br ...
Writing to build/Release/re2.node ...
The verification has failed: building from sources ...
Building locally ...

> re2@1.20.3 rebuild
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@14.17.6 | darwin | x64
gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: Cannot find module 'node:events'
gyp ERR! stack Require stack:
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/node_modules/minipass/dist/cjs/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/dist/cjs/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/node_modules/glob/dist/cjs/glob.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/node_modules/glob/dist/cjs/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/node_modules/glob/dist/cjs/index-cjs.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/lib/util/glob.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/lib/rm.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/lib/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/cache/entry.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/cache/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/fetch.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/node-gyp/lib/install.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/node-gyp/lib/node-gyp.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/node-gyp/bin/node-gyp.js
gyp ERR! stack     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
gyp ERR! stack     at Function.Module._load (internal/modules/cjs/loader.js:745:27)
gyp ERR! stack     at Module.require (internal/modules/cjs/loader.js:961:19)
gyp ERR! stack     at require (internal/modules/cjs/helpers.js:92:18)
gyp ERR! stack     at Object.<anonymous> (/Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/node_modules/minipass/dist/cjs/index.js:13:23)
gyp ERR! stack     at Module._compile (internal/modules/cjs/loader.js:1072:14)
gyp ERR! stack     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
gyp ERR! stack     at Module.load (internal/modules/cjs/loader.js:937:32)
gyp ERR! stack     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
gyp ERR! stack     at Module.require (internal/modules/cjs/loader.js:961:19)
gyp ERR! stack     at require (internal/modules/cjs/helpers.js:92:18)
gyp ERR! stack     at Object.<anonymous> (/Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/dist/cjs/index.js:36:20)
gyp ERR! stack     at Module._compile (internal/modules/cjs/loader.js:1072:14)
gyp ERR! stack     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
gyp ERR! stack     at Module.load (internal/modules/cjs/loader.js:937:32)
gyp ERR! stack     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
gyp ERR! System Darwin 22.5.0
gyp ERR! command "/Users/dana/Sites/node_modules/node/bin/node" "/Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2
gyp ERR! node -v v14.17.6
gyp ERR! node-gyp -v v9.4.0
gyp ERR! Node-gyp failed to build your package.
gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "7".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v18.17.1

> re2@1.20.3 rebuild
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@14.17.6 | darwin | x64
gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: Cannot find module 'node:events'
gyp ERR! stack Require stack:
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/node_modules/minipass/dist/cjs/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/dist/cjs/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/node_modules/glob/dist/cjs/glob.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/node_modules/glob/dist/cjs/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/node_modules/glob/dist/cjs/index-cjs.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/lib/util/glob.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/lib/rm.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/cacache/lib/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/cache/entry.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/cache/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/fetch.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/make-fetch-happen/lib/index.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/node-gyp/lib/install.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/node-gyp/lib/node-gyp.js
gyp ERR! stack - /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/node-gyp/bin/node-gyp.js
gyp ERR! stack     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
gyp ERR! stack     at Function.Module._load (internal/modules/cjs/loader.js:745:27)
gyp ERR! stack     at Module.require (internal/modules/cjs/loader.js:961:19)
gyp ERR! stack     at require (internal/modules/cjs/helpers.js:92:18)
gyp ERR! stack     at Object.<anonymous> (/Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/node_modules/minipass/dist/cjs/index.js:13:23)
gyp ERR! stack     at Module._compile (internal/modules/cjs/loader.js:1072:14)
gyp ERR! stack     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
gyp ERR! stack     at Module.load (internal/modules/cjs/loader.js:937:32)
gyp ERR! stack     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
gyp ERR! stack     at Module.require (internal/modules/cjs/loader.js:961:19)
gyp ERR! stack     at require (internal/modules/cjs/helpers.js:92:18)
gyp ERR! stack     at Object.<anonymous> (/Users/dana/Sites/ghost/versions/5.61.1/node_modules/path-scurry/dist/cjs/index.js:36:20)
gyp ERR! stack     at Module._compile (internal/modules/cjs/loader.js:1072:14)
gyp ERR! stack     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
gyp ERR! stack     at Module.load (internal/modules/cjs/loader.js:937:32)
gyp ERR! stack     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
gyp ERR! System Darwin 22.5.0
gyp ERR! command "/Users/dana/Sites/node_modules/node/bin/node" "/Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/dana/Sites/ghost/versions/5.61.1/node_modules/re2
gyp ERR! node -v v14.17.6
gyp ERR! node-gyp -v v9.4.0
gyp ERR! Node-gyp failed to build your package.
gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.

yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Exit code: 7

Debug Information:
    OS: macOS, v13.4.1
    Node Version: v18.17.1
    Ghost-CLI Version: 1.24.2
    Environment: development
    Command: 'ghost install local'

Thoughts:

  • I have uninstalled all node/npm/packages and then reinstalled everything (using n)
  • I have tried with both node 16 and 18
  • There are a few errors being displayed here, and i’m not sure which one is the root cause
  • “Command failed: yarn install --no-emoji --no-progress” is the first error to be displayed but I’m not sure it matters
  • gyp is trying to build re2 using node 14, which causes an error for missing node:events, which was only added in node 16. I can’t figure out how to force gyp to use a different node version, but I don’t know if this is the actual problem
  • I can install re2 outside of gyp without problems using npm install --save re2 as per the re2 GitHub repo, but ghost doesn’t detect that it’s been installed
  • I’ve looked through GitHub for re2 (https://github.com/uhop/node-re2/issues) and node-gyp (https://github.com/nodejs/node-gyp/issues) but have not been able to find a related issue

Any help moving this forward would be appreciated!

Somewhere on your system you have Node 14 installed. That version of Node doesn’t contain the node:events module, causing failure.

Given that node --version returns a newer version, that’s confusing. You could try using locate bin/node to find all your Node binaries and see about uninstalling the old version.

Or, if you need that for something else, try reviewing and updating the $PATH environment variable to make sure the path where the newer version is found comes first. But the fact that node --version shows a newer version already suggests that $PATH may be set directly. It could be some script has hard-coded a path like /usr/bin/node which is why is it’s loading an older version.

1 Like

Thanks @markstos - I solved this after your suggestion!

It turns out I didn’t have another copy of node installed, but this got me digging around a bit. I was able to successfully ghost install local from a folder located in ~/Downloads, but not in ~/Sites where it was pulling in node14

The problem is that I had an old node_modules folder in the parent folder of where I ran running ghost install local. It was just a temporary throwaway folder from some point in the past that I never deleted. And node-gyp traversed the folders down from where I was running ghost install local into ~/Sites, saw the node_modules folder existed in ~/Sites, and decided node 14 was the right thing to use.

~/Sites/ghostsiteghost install local here
~/Sites/node_modules → old garbage files

Once I removed the old node_modules folder, everything worked as expected.

2 Likes