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?
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
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
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.
Had the same issue, then noted that sequelize-cli
is the way to go ahead.
npm install -g sequelize-cli
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
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.
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
The following steps worked on Pop!_OS 20.10 & ubuntu 20.04
npm install -g sequelize-cli
Problem : Unknown command: "sequelize" Solve : npx sequelize init
first install npm install sequelize sequelize-cli After that run npx sequelize init instead of sequelize init That works for me
I also got the message: zsh: command not found: sequelize and npx sequelize init instead of sequelize init solved the problem for me
npx sequelize-cli <command>
For the latest version, That works for me.
npm install -g sequelize-cli
this working. We need to install sequence globally
To resolve the issue, install Sequelize CLI globally using the command:
npm install -g sequelize-cli
After installation, retry the sequelize init
command, and it should work as expected.
I had same problem. I cd to
<proj_dir>\node_modules\sequelize-automate\bin
from there I ran
node sequelize-automate -t js -h localhost -d <proj_dir> -u postgres -p ****** -P 5432 -e postgres -o root to \src\models
command. It worked like charm.
worked on windows os
open powershell as an admistrator after that run following commands:
Set-ExecutionPolicy RemoteSigned Get-ExecutionPolicy -List LSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine after step 3 press A for all
work for me......
if you're using Yarn
yarn global add sequelize-cli --prefix /usr/local
And run
sequelize init
I tried to initialize a Sequelize project using npm init sequelize, but I encountered an error:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/create-sequelize - Not found
However, I managed to resolve the issue by using
npx sequelize init
.
When you run npx sequelize init, it's akin to running the locally or globally installed Sequelize CLI's init command, bypassing the need to look for a package like create-sequelize.
© 2022 - 2024 — McMap. All rights reserved.