`ghost run` works, `ghost start` doesn’t, oembed-parser issue?

I recently upgraded from 2.x to 3.x but I had an issue where I got a 500 error when attempting to upload images using the admin and I decided to run updates and restart the server.

After restarting the server, ghost did not start.

When I run ghost start it hangs for a very long time with:

+ sudo systemctl is-active ghost_138-68-63-196
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
+ sudo systemctl is-active ghost_138-68-63-196
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
+ sudo systemctl start ghost_138-68-63-196
☴ Starting Ghost: 138-68-63-196

and eventually fails with this message:


A GhostError occurred.

Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_138-68-63-196 -n 50

Debug Information:
    OS: Ubuntu, v18.04.3 LTS
    Node Version: v10.13.0
    Ghost Version: 3.1.0
    Ghost-CLI Version: 1.13.1
    Environment: production
    Command: 'ghost start'

Additional log info available in: /home/ghost-mgr/.ghost/logs/ghost-cli-debug-2019-11-30T04_46_30_099Z.log

Try running ghost doctor to check your system for known issues.

You can always refer to https://ghost.org/docs/api/ghost-cli/ for troubleshooting.

When I run the suggested journalctl -u ghost_138-68-63-196 -n 50, this looks interesting:

 (node:6625) Warning: require() of ES modules is not supported.
 require() of /var/www/ghost/versions/3.1.0/node_modules/oembed-parser/index.js from /var/www/ghost/versions/3.1.0/core/server/overrides.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
 Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /var/www/ghost/versions/3.1.0/node_modules/oembed-parser/package.json.
 internal/modules/cjs/loader.js:1156
       throw new ERR_REQUIRE_ESM(filename);
       ^
 Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /var/www/ghost/versions/3.1.0/node_modules/oembed-parser/index.js
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:13)
     at Module.load (internal/modules/cjs/loader.js:976:32)
     at Function.Module._load (internal/modules/cjs/loader.js:884:14)
     at Module.require (internal/modules/cjs/loader.js:1016:19)
     at require (internal/modules/cjs/helpers.js:69:18)
     at Object.<anonymous> (/var/www/ghost/versions/3.1.0/core/server/overrides.js:16:32)
     at Module._compile (internal/modules/cjs/loader.js:1121:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
     at Module.load (internal/modules/cjs/loader.js:976:32)
     at Function.Module._load (internal/modules/cjs/loader.js:884:14) {
   code: 'ERR_REQUIRE_ESM'
 }
 ghost_138-68-63-196.service: Service hold-off time over, scheduling restart.
 ghost_138-68-63-196.service: Scheduled restart job, restart counter is at 5.
 Stopped Ghost systemd service for blog: 138-68-63-196.
 ghost_138-68-63-196.service: Start request repeated too quickly.
 ghost_138-68-63-196.service: Failed with result 'start-limit-hit'.
 Failed to start Ghost systemd service for blog: 138-68-63-196.

I’m going to look into that specific oembed-parser lib, but I haven’t yet.

The odd thing is that if I run ghost run, it does start. I see the following when I do:

The `ghost run` command is used by the configured Ghost process manager and for debugging. If you're not running this to debug something, you should run `ghost start` instead.
+ sudo node current/index.js
[2019-11-30 04:53:45] INFO Ghost is running in production...
[2019-11-30 04:53:45] INFO Your site is now available on https://tumbleweird.org/
[2019-11-30 04:53:45] INFO Ctrl+C to shut down
[2019-11-30 04:53:45] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-11-30 04:53:45] WARN Tries: 0
[2019-11-30 04:53:45] WARN Retrying...
[2019-11-30 04:53:45] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-11-30 04:53:45] WARN Tries: 1
[2019-11-30 04:53:45] WARN Retrying...
[2019-11-30 04:53:45] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-11-30 04:53:45] WARN Tries: 2
[2019-11-30 04:53:45] WARN Retrying...
[2019-11-30 04:53:45] WARN Can't connect to the bootstrap socket (localhost 8000) ECONNREFUSED
[2019-11-30 04:53:45] INFO Ghost boot 4.615s

It did seem like that could even be related to my images uploading issue, and so while I had the server running via ghost run, I attempted to upload an image in a post and it worked perfectly. (Previously, it was spitting a 500 error when attempting to upload an image.)

Because I expect I’ll get asked, running ghost doctor gives me the following, indicating things are fine:

✔ Checking system Node.js version
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_138-68-63-196
+ sudo systemctl reset-failed ghost_138-68-63-196
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies

Definitely not the ““correct”” way to fix this, but I just removed type: ‘module’ from node_modules/oembed-parser/package.json and then running ghost start worked like expected.

However, the image upload is still broken. (It had briefly worked again when using ghost run prior to editing the oembed-parser package file, as described above.)

Overall this does seem like a ghost issue somewhere.