Steps and versions for local dev setup?

Howdy, I have spent hours today trying to get a local dev setup working from source using these docs: https://ghost.org/docs/install/source/

Not getting anywhere and wondering if I’m using a bad Yarn version or if you can provide any other guidance?

What Node version, database, OS & browser are you using?

  • using nvm, have tried Node 16 and Node 18
  • Yarn 3.6 with both versions of Node
  • Mac OS Ventura, Intel not M1

What errors or information do you see in the console?

  • https://ghost.org/docs/install/source/#prerequisites doesn’t work because Yarn 3 doesn’t have global installs. I tried to get around this with npm install -g knex-migrator and same with ember-cli. Is this reasonable workaround?
  • Supported node versions for self-hosted installs of Ghost says that “Ghost’s current recommended Node version is Node v16 LTS.” but then in the table below, says 18.x (Node v18 Hydrogen LTS) Recommended… so which is recommended?
  • back to https://ghost.org/docs/install/source/#run-setup--installation, yarn setup never successfully runs, more info below

What steps could someone else take to reproduce the issue you’re having?

With Node 16 or 18 and Yarn 3.6:

Desktop % npm install ghost-cli@latest -g
Desktop % npm install -g ember-cli 
Desktop % npm install -g knex-migrator

then repo steps from Ghost Docs
then

Ghost % corepack enable # to get yarn
Ghost % yarn setup
Internal Error: ghost-monorepo@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile

Hmm okay, let’s do what it says:

Ghost % yarn install
...
➤ YN0058: │ ember-power-datepicker@https://github.com/cibernox/ember-power-datepicker.git#commit=da580474a2c449b715444934ddb626b7c07f46a7: Packing the package failed (exit code 1, logs can be found here: /private/var/folders/z8/9mv15y0s3tvft80885n7jcqh0000gn/T/xfs-1ba6fa9e/pack.log)
➤ YN0000: └ Completed in 3m 55s
➤ YN0000: Failed with errors in 3m 55s

Maybe something weird with that commit/release of ember-power-datepicker… let’s delete yarn.lock and try again

Ghost % rm yarn.lock
Ghost % yarn install
...
➤ YN0000: Done with warnings in 19m 47s

Woohoo! Ready to try setup again:

Ghost % yarn setup
...
[2023-06-24 00:13:31] ERROR Cannot find module '/Desktop/Ghost/node_modules/@tryghost/post-revisions/build/index.js'. Please verify that the package.json has a valid "main" entry

Error: Cannot find module '/Desktop/Ghost/node_modules/@tryghost/post-revisions/build/index.js'. Please verify that the package.json has a valid "main" entry
    at /Desktop/Ghost/node_modules/knex-migrator/lib/index.js:240:23
    at tryPackage (node:internal/modules/cjs/loader:425:19)
...

Surely this is not how this process is supposed to go! Thanks in advance for any help.

for posterity, the magic combo seems to be:

  • Yarn 1.22.19 :sweat_smile:
  • at least Node 18 for yarn dev
1 Like

Hmmm…guessing you don’t remember if you did anything else here to go this going?

I got same exact error as you

2023-06-24 00:13:31] ERROR Cannot find module '/Desktop/Ghost/node_modules/@tryghost/post-revisions/build/index.js'. Please verify that the package.json has a valid "main" entry

Error: Cannot find module '/Desktop/Ghost/node_modules/@tryghost/post-revisions/build/index.js'. Please verify that the package.json has a valid "main" entry
    at /Desktop/Ghost/node_modules/knex-migrator/lib/index.js:240:23
    at tryPackage (node:internal/modules/cjs/loader:425:19)

And modified my environment to match your solution, and still same error…

I just came across this issue installing the dev setup. I assume it’s because I initially tried to install using an unsupported node.js version (21.2.0). What I ended up doing was running yarn fix as specified in the ‘Troubleshooting’ section of the install steps and the error didn’t re-appear.

It’s also possible that running yarn setup multiple times causes the issue. If you run yarn dev does it work?