Upgrading to NodeJS 10 broke Ghost

If you’re looking for some help, it’s important to provide as much context as possible so that people are able to assist you. Try to always mention:

  • What’s your URL? This is the easiest way for others to debug your issue
  • What version of Ghost are you using? v2.13.2
  • What configuration? Ghost running on Ubuntu 18.04LTS on AWS EC2 with the database on Amazon RDB (mysql).
  • What browser? Safari 12
  • What errors or information do you see in the console?

/var/www/ghost$ ghost run
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
    events.js:174
    throw er; // Unhandled ‘error’ event
    ^

Error: shutdown ENOTCONN
at TLSSocket.Socket._final (net.js:364:25)
at callFinal (_stream_writable.js:612:10)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted ‘error’ event at:
at Connection._handleProtocolError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/Connection.js:425:8)
at Protocol.emit (events.js:189:13)
at Protocol._delegateError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/protocol/Protocol.js:390:10)
at Protocol.handleNetworkError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/protocol/Protocol.js:363:10)
at Connection._handleNetworkError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/Connection.js:420:18)
at TLSSocket. (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/Connection.js:305:20)
at TLSSocket.emit (events.js:189:13)
at TLSSocket._tlsError (_tls_wrap.js:612:8)
at TLSSocket.emit (events.js:189:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)

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

I had a working Ghost v2.13.2 environment on Node v8.15.0LTS. I noticed in the release notes for Ghost v2.13.2 that Node v10 was recommended. I tried installing Node v10.15.1LTS using the following commands:

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash
sudo apt-get install -y nodejs

Now Ghost won’t start. ghost run shows the error above.

My config.production.json is
“database”: {
“client”: “mysql”,
“connection”: {
“host”: “”,
“user”: “”,
“password”: “”,
“database”: “ghost_prod”,
“ssl”: “Amazon RDS”
}

Hi,
Just to confirm that on my stack, ghost runs smoothly on node 10.15.x for over than 6 months.
Cheers!

I also just recently updated node to 10.15 and it works ok (ubuntu 16.04).

What does ghost doctor tell you?

You’d need to reinstall all of Ghost’s dependencies after upgrading Node, as the dependencies you have are compiled for the old version.

The easiest way to achieve this smoothly is to update Node, and then update Ghost. Seems like you had already updated to the latest version though.

I think you can trigger a reinstall with ghost update --force.

If not, then ghost update --rollback and then deleting the 2.13.2 folder from versions, and updating again should work.

If you can confirm that’s the issue that would be very helpful, we should probably have a shortcut command for refreshing dependences when updating Node, and some docs to cover how to do this safely.

Thanks glad to know it should work!

Do you mind sharing how you upgraded the Node version?

ghost doctor shows that everything is okay.

/var/www/ghost $ ghost doctor
✔ 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
+ sudo systemctl is-active ghost_cybersecureme-net
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability

Hey Hannah.

Ok so thankfully I took a snapshot before I updated. So I rolled back my disk image and tried again. This time I updated Node first.

Here is the setup that was working.
$ node -v
v8.15.0
$ ghost version
Ghost-CLI version: 1.9.9
Ghost version: 2.13.1 (at /var/www/ghost)

Then I updated Node:
$ ghost stop
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash

## Installing the NodeSource Node.js 10.x repo...

## Populating apt-get cache...

+ apt-get update
Get:1 https://deb.nodesource.com/node_8.x bionic InRelease [4622 B]
Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease                                                                   
Get:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                          
Get:4 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                         
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                       
Get:6 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main Sources [245 kB]
Get:7 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [519 kB]           
Get:8 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [194 kB]                    
Get:9 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [726 kB]                  
Get:10 http://security.ubuntu.com/ubuntu bionic-security/main Sources [74.4 kB]                                 
Get:11 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [264 kB]
Get:12 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [98.8 kB]
Fetched 2378 kB in 1s (1829 kB/s)        
Reading package lists... Done

## Confirming "bionic" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_10.x/dists/bionic/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK

## Creating apt sources list file for the NodeSource Node.js 10.x repo...

+ echo 'deb https://deb.nodesource.com/node_10.x bionic main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_10.x bionic main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease                                                
Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease                                              
Get:4 https://deb.nodesource.com/node_10.x bionic InRelease [4584 B]                                                             
Hit:5 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                
Get:6 https://deb.nodesource.com/node_10.x bionic/main amd64 Packages [763 B]
Fetched 5347 B in 1s (10.1 kB/s)                       
Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 10.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
     echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn

$ sudo apt-get install -y nodejs

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
nodejs
1 upgraded, 0 newly installed, 0 to remove and 51 not upgraded.
Need to get 15.1 MB of archives.
After this operation, 7550 kB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_10.x bionic/main amd64 nodejs amd64 10.15.1-1nodesource1 [15.1 MB]
Fetched 15.1 MB in 0s (67.8 MB/s)
(Reading database ... 116052 files and directories currently installed.)
Preparing to unpack .../nodejs_10.15.1-1nodesource1_amd64.deb ...
Detected old npm client, removing...
Unpacking nodejs (10.15.1-1nodesource1) over (8.15.0-1nodesource1) ...
Setting up nodejs (10.15.1-1nodesource1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

$ node -v
v10.15.1

Then I tried updating Ghost.

$ ghost update

+ sudo systemctl is-active ghost_cybersecureme-net
+ sudo systemctl reset-failed ghost_cybersecureme-net
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking for available migrations
✔ Checking for latest Ghost version
✔ Downloading and updating Ghost to v2.13.2
✔ Linking latest Ghost and recording versions
+ sudo systemctl is-active ghost_cybersecureme-net
☱ Downloading and updating Ghost to v2.13.2 > Installing dependencies > [5/5] Building fresh packages...✔ 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_cybersecureme-net
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
+ sudo systemctl start ghost_cybersecureme-net
☱ Restarting Ghost+ sudo systemctl stop ghost_cybersecureme-net
✖ Restarting Ghost
A GhostError occurred.

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

Debug Information:
    OS: Ubuntu, v18.04
    Node Version: v10.15.1
    Ghost-CLI Version: 1.9.9
    Environment: production
    Command: 'ghost update'

Additional log info available in: /home/cybersecureme/.ghost/logs/ghost-cli-debug-2019-02-06T23_45_26_586Z.log

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

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


? Unable to upgrade Ghost from v2.13.1 to v2.13.2. Would you like to revert back to v2.13.1? (Y/n) Yes

+ sudo systemctl is-active ghost_cybersecureme-net
+ sudo systemctl reset-failed ghost_cybersecureme-net
✔ Checking system Node.js version
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking for available migrations
✔ Checking for latest Ghost version
ℹ Downloading and updating Ghost [skipped]
+ sudo /var/www/ghost/current/node_modules/.bin/knex-migrator-rollback --force --v 2.13.1 --mgpath /var/www/ghost/current
✖ Rolling back database migrations
A GhostError occurred.

Message: The database migration in Ghost encountered an error.
Help: https://docs.ghost.org/faq/upgrade-to-ghost-2-0/#what-to-do-when-an-upgrade-fails
Suggestion: ghost update --rollback

Debug Information:
OS: Ubuntu, v18.04
Node Version: v10.15.1
Ghost-CLI Version: 1.9.9
Environment: production
Command: 'ghost update'

Additional log info available in: /home/cybersecureme/.ghost/logs/ghost-cli-debug-2019-02-06T23_46_28_033Z.log

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

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

Contents of the first log file from the upgrade
cat /home/cybersecureme/.ghost/logs/ghost-cli-debug-2019-02-06T23_45_26_586Z.log

Debug Information:
    OS: Ubuntu, v18.04
    Node Version: v10.15.1
    Ghost-CLI Version: 1.9.9
    Environment: production
    Command: 'ghost update'
Message: Could not communicate with Ghost
Suggestion: journalctl -u ghost_cybersecureme-net -n 50
Stack: Error: Could not communicate with Ghost
    at Server.server.close (/usr/lib/node_modules/ghost-cli/lib/utils/port-polling.js:56:20)
    at Object.onceWrapper (events.js:277:13)
    at Server.emit (events.js:189:13)
    at emitCloseNT (net.js:1616:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Contents of the second log file from the rollback attempt
cat /home/cybersecureme/.ghost/logs/ghost-cli-debug-2019-02-06T23_46_28_033Z.log

Debug Information:
    OS: Ubuntu, v18.04
    Node Version: v10.15.1
    Ghost-CLI Version: 1.9.9
    Environment: production
    Command: 'ghost update'
Message: The database migration in Ghost encountered an error.
Help: https://docs.ghost.org/faq/upgrade-to-ghost-2-0/#what-to-do-when-an-upgrade-fails
Suggestion: ghost update --rollback
Stack: Error: The database migration in Ghost encountered an error.
    at /usr/lib/node_modules/ghost-cli/lib/tasks/migrator.js:41:21
    at process._tickCallback (internal/process/next_tick.js:68:7)

Ghost doctor at this point doesn’t show any problems
ghost doctor

✔ 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
+ sudo systemctl is-active ghost_cybersecureme-net
✔ Validating config
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability

And finally here is the output of ghost run showing the original error
ghost run
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
events.js:174
throw er; // Unhandled ‘error’ event
^

Error: shutdown ENOTCONN
    at TLSSocket.Socket._final (net.js:364:25)
    at callFinal (_stream_writable.js:612:10)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
    at Connection._handleProtocolError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/Connection.js:425:8)
    at Protocol.emit (events.js:189:13)
    at Protocol._delegateError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/protocol/Protocol.js:390:10)
    at Protocol.handleNetworkError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/protocol/Protocol.js:363:10)
    at Connection._handleNetworkError (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/Connection.js:420:18)
    at TLSSocket.<anonymous> (/var/www/ghost/versions/2.13.2/node_modules/mysql/lib/Connection.js:305:20)
    at TLSSocket.emit (events.js:189:13)
    at TLSSocket._tlsError (_tls_wrap.js:612:8)
    at TLSSocket.emit (events.js:189:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I’m stumped… Am I trying to upgrade Node the right way for Ghost? I’ve never had issues just installing the newer version over the old version of Node.

Thank for all your help.

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