Since couple weeks I was trying to update ghost to the latest version, but I was getting the same error, I thought it was a bug in Ghost-cli or from dependencies, but I was wrong.
The error that I am talking is this one:
Debug Information: OS: Ubuntu, v16.04 Node Version: v6.14.2 Ghost-CLI Version: 1.7.3 Environment: production Command: 'ghost install' Message: The database migration in Ghost encountered an error. Help: https://docs.ghost.org/v1/docs/troubleshooting#section-general-update-error --------------- stderr --------------- /srv/www/versions/1.22.8/node_modules/knex-migrator/lib/utils.js:11 let files = , ^^^ SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:374:25) at Object.Module._extensions..js (module.js:417:10) at Module.load (module.js:344:32) at Function.Module._load (module.js:301:12) at Module.require (module.js:354:17) at require (internal/module.js:12:17) at Object.<anonymous> (/srv/www/versions/1.22.8/node_modules/knex-migrator/bin/knex-migrator-migrate:4:13) at Module._compile (module.js:410:26) at Object.Module._extensions..js (module.js:417:10)
Node.js supports ES6 very well in the version 6 as you can see in node.green. There is not a bug report about this issue in the Ghost repository so I realize it was an installation issue.
I have node.js on NVM, also I am running Ubuntu with a different node.js installation via ubuntu repositories.
Ghost-CLI like other tools use the path
/usr/bin/node it is a symlink, this means it can be overwritten by a new upgrade or installation so if you upgrade node.js on Ubuntu it can overwrite the symlink with the new version.
If you are using NVM or another Node.js installation you need to overwrite the symlink, with this command:
sudo ln -sf $(which node) /usr/bin/node
$(which node) is your current Node.js path if you want to use a different one you have to put it there.