'startsWith' error when running 'ghost start'

I’m trying to run Ghost locally to do some minor theme customisation of the “Edition” theme. I am not able to run ‘ghost start’.

Ghost was working fine for me before. Yesterday, I updated everything to the latest version of Ghost and the Ghost-cli. Things still worked yesterday. I have no idea what changed between yesterday and today, but now when I try “ghost start”, I get the following.

Debug Information:
    OS: macOS, v11.2.3
    Node Version: v14.16.0
    Ghost Version: 4.4.0
    Ghost-CLI Version: 1.17.2
    Environment: production
    Command: 'ghost start'
An error occurred.
Message: 'Cannot read property 'startsWith' of undefined'

Stack: TypeError: Cannot read property 'startsWith' of undefined
    at StartCommand.run (/Users/sambeckbessinger/.nvm/versions/node/v14.16.0/lib/node_modules/ghost-cli/lib/commands/start.js:37:61)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Function._run (/Users/sambeckbessinger/.nvm/versions/node/v14.16.0/lib/node_modules/ghost-cli/lib/command.js:190:13)

I used nvm, and have already tried setting my Node version to 12 and 16, and neither worked. I’m on a Mac.

I have already tried these commands:

  • sudo npm install -g ghost-cli@latest
  • ghost update
  • ghost doctor

None of them had any errors.

Any idea what might be going on, good people of the Ghost Forum?

1 Like

Can you try running ghost start --development since you’re running on a mac? If that doesn’t work, what’s the output of ghost config get url?

I have a similar issue. ghost start --development solves changes the problem. It creates a new sqlite database named ghost-dev instead of using the previous one ghost-local. So the previous content is not available.

And ghost start -D --dbpath content/data/ghost-local.db doesn’t make the previous data and users come back.

The problem with ghost start is probably related to the absence of the production config. Do I need the production config during the development? However, ghost config get url reads the development config fine:

$ ghost config get url
Found a development config but not a production config, running in development mode instead
http://localhost:2368/

My bad. There’s no --dbpath flag for ghost start, it was for ghost config. Starting with ghost start -D creates content/data/ghost-dev.db by default, removing it and editing config.development.json pointing to the correct database solved the problem (why the CLI tool didn’t read ghost-local.db before?). After that, ghost start -D worked okay.

@iharsuvorau thanks for the report! looks like this was a small bug with some url warnings we introduced in v1.17.2, should have it fixed shortly.

Alright - if you update to Ghost-CLI 1.17.3 that error should have gone away (i.e. ghost start should work as it did before). Let us know if you run into any more issues :grinning_face_with_smiling_eyes:

1 Like

Thanks for helping with this! Unfortunately, it’s still not working for me.

I can’t seem to get ghost-cli to update. I tried yarn global add ghost-cli@latest and yarn global add ghost-cli@1.17.3. Both times, I got to the success message: success Installed "ghost-cli@1.17.3" with binaries:.

But when I then tried to run ghost start or ghost start --development I get the same startsWith error message, and super-weird, the Debug Info tells me that Ghost-CLI is still on 1.17.2.

sambeckbessinger@Sams-MacBook-Pro ghost % ghost start  
An error occurred.
Message: 'Cannot read property 'startsWith' of undefined'


Debug Information:
    OS: macOS, v11.2.3
    Node Version: v14.16.0
    Ghost Version: 4.4.0
    Ghost-CLI Version: 1.17.2
    Environment: production
    Command: 'ghost start'

Additional log info available in: /Users/sambeckbessinger/.ghost/logs/ghost-cli-debug-2021-05-24T07_34_39_495Z.log

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

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

Super weird, right? I have tried restarting my terminal, and it didn’t help. I also tried ghost start --development.

ghost config get url gives me http://localhost:2368/

How did you initially install ghost-cli? If you installed it with npm (npm i -g ghost-cli@latest), it might still exist which is why the CLI is still at 1.17.2

You can run whereis ghost to see all of the locations the cli exists, and which ghost to see which location is actually used

Unfortunately this can only be fixed by upgrading to 1.17.3

Aha! Thanks for the npm tip @vikaspotluri123 :slight_smile: I have now managed to upgrade to 1.17.3 and ghost is starting correctly. Thank you, all!

1 Like