Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-bash: sequelize: command not found

I just ran npm install --save sequelize pg pg-hstore in my project root directory and now I am unable to invoke sequelize init. I get the error: -bash: sequelize: command not found. What am I doing wrong?

like image 927
Tzvetlin Velev Avatar asked Mar 29 '17 17:03

Tzvetlin Velev


3 Answers

The reason is: sequelize is not installed globally on your cli. To get sequelize access to all your cli just do.

npm install -g sequelize-cli

The '-g' means global this will allow you to access sequelize command anywhere in your app directory.

After that you can do eg: sequelize model:generate --name User --attributes firstName:string,lastName:string,email:string,password:string

like image 109
Codedreamer Avatar answered Nov 16 '22 18:11

Codedreamer


I prefer to avoid installing global npm packages. If you have sequelize as a dependency in your package.json, you can utilize sequelize-cli via npx.

$ npx sequelize-cli <command>.

For example, you could do $ npx sequelize-cli migration:generate --name add-a-column to create a migration file.

like image 25
thedanotto Avatar answered Nov 16 '22 19:11

thedanotto


Had the same issue, then noted that sequelize-cli is the way to go ahead.

npm install -g sequelize-cli
like image 16
Dhammika Avatar answered Nov 16 '22 18:11

Dhammika