heroku sequelize: command not found

Viewed 1437

I have installed sequelize cli using the following command

npm install -g sequelize-cli

It works fine on localhost

But when I deploy to heroku and try to run migrations

I get error

sequelize: command not found
2 Answers
  • The package sequelize-cli is installed globally on your system so it's working on your system without any problem.
  • You can not run a script that is installed on your system, on the Heroku.
  • Since Heroku CLI is made to accomplish the operation related to Heroku dynos only i.e. you can only run commands that are predefined in Heroku CLI
  • To run a script on Heroku you have to define it in package and when Heroku will deploy your app it will automatically run that script.

For example:

If you want to run db:migrate using sequelize-cli then do the following steps:

  • add sequelize-cli as a dependency in your package.json
  • add migrate: "sequelize db:migrate" in the scripts.

I am not sure for what purpose you want to run this command. But to run a script on Heroku you have to define it in your package and Heroku will do the rest.

As for me I was trying to run sequelize DB migration to heroku postgress database. As per earlier documentations, or maybe what you tried, was to run the command heroku run sequelize db:migrate

This however is what seems to work now heroku run npx sequelize-cli db:migrate

Related