-bash: sequelize: command not found

Deadly 提交于 2019-12-10 13:35:55

问题


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?


回答1:


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




回答2:


I would like to answer my own question. The global npm install path was wrong for my computer.

npm config get prefix

Then I ran to put the path where it should be. This problem gave me a lot of head aches. Hope it helps someone.

npm config set prefix /usr/local




回答3:


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

npm install -g sequelize-cli



回答4:


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.




回答5:


I had this problem and solved it by running

nvm install node --reinstall-packages-from=node

and then reinstalling

npm install -g sequelize-cli

Before doing this I had an unfortunate Node Version Manager setup. My computer was running something like version 10, but installing sequelize in the path used by version 8.

Now everything is updated and works.




回答6:


if you want to use sequelize-cli without install it globally , you need to run it from node_modules folder in your root project. that is node_modules/.bin/sequelize. try to run node_modules/.bin/sequelize help for more information about sequelize command line



来源:https://stackoverflow.com/questions/43099808/bash-sequelize-command-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!