`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.

1 Like

Hi @adamavenir,

I had the same issue and the fix you suggested worked for me. It’s not an ideal solution but at least i’m able to start ghost ! THANKS

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.

The correct fix here is to upgrade Ghost ;-) The dependency was upgraded to a fixed version towards the end of last year.

This was fixed in Ghost 3.9.0 released around a month ago. If you’re upgrading I’d suggest going up to the latest however which is 3.12.1 at time of writing but can always be found here Releases · TryGhost/Ghost · GitHub.

1 Like

Having a similar issue where it stalls on Starting Ghost, but different error - after updating to:

Ghost-CLI version: 1.13.1
Ghost version: 3.12.1

Running Ubuntu Ghost on 18.04

journalctl:

- Inspecting operating system
 /var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
       } catch {
               ^
 SyntaxError: Unexpected token {
     at createScript (vm.js:80:10)
     at Object.runInThisContext (vm.js:139:10)
     at Module._compile (module.js:616:28)
     at Object.Module._extensions..js (module.js:663:10)
     at Module.load (module.js:565:32)
     at tryModuleLoad (module.js:505:12)
     at Function.Module._load (module.js:497:3)
     at Module.require (module.js:596:17)
     at require (internal/module.js:11:18)
     at Object.<anonymous> (/var/www/ghost/versions/3.12.1/node_modules/fs-extra/lib/mkdirs/index.js:3:44
Service hold-off time over, scheduling restart.
Scheduled restart job, restart counter is at 99.

If I run ghost with NODE_ENV=production ghost run it starts…

@danhi it looks like you’re running into the same issue as this thread:

Can you answer the questions that were posed in that thread?

indeed seems so - thanks for redirecting! ok so here are the two versions:

Using n as node manager

nodejs -v
v8.10.0

node -v
v12.13.1

which nodejs
/usr/bin/nodejs

which node
/usr/local/bin/node

It definitely looks like you have 2 versions of node, and it seems that ghost is using nodejs, the version which is not supported. I’m not entirely sure how to get rid of it (or if you can; you might have other apps that depend on it), but my suggestion is to look into that :slight_smile:

Fixed! Although oblivious of why it occurred in the first place…

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gyp javascript-common libc-ares2 libhttp-parser2.7.1 libjs-async
  libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libssl1.0-dev
  libuv1-dev nodejs-doc python-pkg-resources
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  node-abbrev node-ansi node-ansi-color-table node-archy node-async
  node-balanced-match node-block-stream node-brace-expansion
  node-builtin-modules node-combined-stream node-concat-map node-cookie-jar
  node-delayed-stream node-forever-agent node-form-data node-fs.realpath
  node-fstream node-fstream-ignore node-github-url-from-git node-glob
  node-graceful-fs node-gyp node-hosted-git-info node-inflight node-inherits
  node-ini node-is-builtin-module node-isexe node-json-stringify-safe
  node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp
  node-mute-stream node-node-uuid node-nopt node-normalize-package-data
  node-npmlog node-once node-osenv node-path-is-absolute node-pseudomap
  node-qs node-read node-read-package-json node-request node-retry
  node-rimraf node-semver node-sha node-slide node-spdx-correct
  node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent
  node-underscore node-validate-npm-package-license node-which node-wrappy
  node-yallist nodejs nodejs-dev npm
0 upgraded, 0 newly installed, 65 to remove and 0 not upgraded.
After this operation, 32.9 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 102651 files and directories currently installed.)
Removing npm (3.5.2-0ubuntu4) ...
Removing node-gyp (3.6.2-1ubuntu1) ...
Removing node-nopt (3.0.6-3) ...
Removing node-abbrev (1.0.9-1) ...
Removing node-ansi-color-table (1.0.0-1) ...
Removing node-npmlog (0.0.4-1) ...
Removing node-ansi (0.3.0-2ubuntu1) ...
Removing node-archy (1.0.0-1ubuntu1) ...
Removing node-request (2.26.1-1) ...
Removing node-form-data (0.1.0-1) ...
Removing node-async (0.8.0-3) ...
Removing node-fstream-ignore (0.0.6-2) ...
Removing node-tar (2.2.1-1) ...
Removing node-fstream (1.0.10-1ubuntu0.18.04.1) ...
Removing node-rimraf (2.6.2-1) ...
Removing node-read-package-json (1.2.4-1) ...
Removing node-glob (7.1.2-4) ...
Removing node-minimatch (3.0.4-3) ...
Removing node-brace-expansion (1.1.8-1) ...
Removing node-balanced-match (0.4.2-1) ...
Removing node-block-stream (0.0.9-1ubuntu1) ...
Removing node-normalize-package-data (2.3.5-2) ...
Removing node-is-builtin-module (1.0.0-1) ...
Removing node-builtin-modules (1.1.1-1) ...
Removing node-combined-stream (0.0.5-1) ...
Removing node-concat-map (0.0.1-1) ...
Removing node-cookie-jar (0.3.1-1) ...
Removing node-delayed-stream (0.0.5-1) ...
Removing node-forever-agent (0.5.1-1) ...
Removing node-fs.realpath (1.0.0-1) ...
Removing node-github-url-from-git (1.4.0-1) ...
Removing node-graceful-fs (4.1.11-1) ...
Removing node-hosted-git-info (2.5.0-1) ...
Removing node-inflight (1.0.6-1) ...
Removing node-inherits (2.0.3-1) ...
Removing node-ini (1.3.4-1) ...
Removing node-which (1.3.0-1) ...
Removing node-isexe (2.0.0-3) ...
Removing node-json-stringify-safe (5.0.0-1) ...
Removing node-lockfile (0.4.1-1) ...
Removing node-lru-cache (4.1.1-1) ...
Removing node-mime (1.3.4-1) ...
Removing node-mkdirp (0.5.1-1) ...
Removing node-read (1.0.7-1) ...
Removing node-mute-stream (0.0.7-1) ...
Removing node-node-uuid (1.4.7-5) ...
Removing node-once (1.4.0-2ubuntu1) ...
Removing node-osenv (0.1.4-1) ...
Removing node-path-is-absolute (1.0.0-1) ...
Removing node-pseudomap (1.0.2-1) ...
Removing node-qs (2.2.4-1ubuntu1) ...
Removing node-retry (0.10.1-1) ...
Removing node-semver (5.4.1-1) ...
Removing node-sha (1.2.3-1) ...
Removing node-slide (1.1.6-1) ...
Removing node-validate-npm-package-license (3.0.1-1) ...
Removing node-spdx-correct (1.0.2-1) ...
Removing node-spdx-expression-parse (1.0.4-1) ...
Removing node-spdx-license-ids (1.2.2-1) ...
Removing node-tunnel-agent (0.3.1-1) ...
Removing node-underscore (1.8.3~dfsg-1) ...
Removing node-wrappy (1.0.2-1) ...
Removing node-yallist (2.0.0-1) ...
Removing nodejs-dev (8.10.0~dfsg-2ubuntu0.4) ...
Removing nodejs (8.10.0~dfsg-2ubuntu0.4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gyp javascript-common libc-ares2 libhttp-parser2.7.1 libjs-async
  libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libssl1.0-dev
  libuv1-dev nodejs-doc python-pkg-resources
0 upgraded, 0 newly installed, 13 to remove and 0 not upgraded.
After this operation, 16.6 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 99000 files and directories currently installed.)
Removing gyp (0.1+20150913git1f374df9-1ubuntu1) ...
Removing javascript-common (11) ...
Removing libc-ares2:amd64 (1.14.0-1) ...
Removing libhttp-parser2.7.1:amd64 (2.7.1-2) ...
Removing libjs-async (0.8.0-3) ...
Removing libjs-inherits (2.0.3-1) ...
Removing libjs-jquery (3.2.1-1) ...
Removing libjs-node-uuid (1.4.7-5) ...
Removing libjs-underscore (1.8.3~dfsg-1) ...
Removing libssl1.0-dev:amd64 (1.0.2n-1ubuntu5.3) ...
Removing libuv1-dev:amd64 (1.18.0-3) ...
Removing nodejs-doc (8.10.0~dfsg-2ubuntu0.4) ...
Removing python-pkg-resources (39.0.1-2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
ghost start
+ sudo systemctl is-active 
+ sudo systemctl reset-failed 
✔ 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 
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
+ sudo systemctl start 
+ sudo systemctl stop 
✖ Starting Ghost: 
A GhostError occurred.

Message: Could not communicate with Ghost
Suggestion: journalctl -u  -n 50

Debug Information:
    OS: Ubuntu, v18.04.4 LTS
    Node Version: v12.13.1
    Ghost Version: 3.12.1
    Ghost-CLI Version: 1.13.1
    Environment: production
    Command: 'ghost start'
journalctl
myblog.service: Failed to execute command: No such file or directory
myblog.service: Failed at step EXEC spawning /usr/bin/node: No such file or directory
sudo apt install nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 16.2 MB of archives.
After this operation, 81.1 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_10.x bionic/main amd64 nodejs amd64 10.19.0-1nodesource1 [16.2 MB]
Fetched 16.2 MB in 0s (46.4 MB/s)
Selecting previously unselected package nodejs.
(Reading database ... 98650 files and directories currently installed.)
Preparing to unpack .../nodejs_10.19.0-1nodesource1_amd64.deb ...
Unpacking nodejs (10.19.0-1nodesource1) ...
Setting up nodejs (10.19.0-1nodesource1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
nodejs -v
v10.19.0
ghost start
+ sudo systemctl is-active ghost_myblog
✔ 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_myblog
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
+ sudo systemctl start ghost_myblog
+ sudo systemctl is-enabled ghost_myblog
✔ Starting Ghost: myblog

Closing this topic because the oembed issue is fixed and it’s getting unrelated posts :slight_smile:

If ghost run works but ghost start is failing then it’s likely you have two different node versions installed - there are other topics on the forum that handle resolving such problems.