-bash: sequelize: command not found
Asked Answered
C

17

41

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?

Cormorant answered 29/3, 2017 at 17:3 Comment(1)
Possible duplicate of How do I install the sequelize.js binary?Veasey
C
8

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

Cormorant answered 29/3, 2017 at 17:21 Comment(0)
D
73

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

Diamine answered 30/4, 2018 at 21:6 Comment(1)
thanks. it's workingRestore
A
30

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.

Annecorinne answered 7/5, 2019 at 19:1 Comment(1)
Thank you .. adding "npx" solving my issue.Trochal
S
17

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

npm install -g sequelize-cli
Sloan answered 2/8, 2017 at 4:58 Comment(0)
C
8

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

Cormorant answered 29/3, 2017 at 17:21 Comment(0)
S
8

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.

Serpentiform answered 25/6, 2019 at 19:14 Comment(0)
C
3

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

Claudio answered 3/8, 2017 at 12:53 Comment(0)
F
2

The following steps worked on Pop!_OS 20.10 & ubuntu 20.04

npm install -g sequelize-cli

Francenefrances answered 17/2, 2021 at 10:44 Comment(0)
S
2

Problem : Unknown command: "sequelize" Solve : npx sequelize init

Shove answered 21/4, 2022 at 13:28 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Usk
S
2

first install npm install sequelize sequelize-cli After that run npx sequelize init instead of sequelize init That works for me

Supereminent answered 8/11, 2022 at 1:37 Comment(0)
C
1

I also got the message: zsh: command not found: sequelize and npx sequelize init instead of sequelize init solved the problem for me

Cite answered 15/4, 2021 at 19:33 Comment(0)
C
1

npx sequelize-cli <command>

For the latest version, That works for me.

Compare answered 11/6, 2022 at 16:30 Comment(0)
R
1

npm install -g sequelize-cli

this working. We need to install sequence globally

Rivero answered 4/9, 2022 at 5:55 Comment(0)
V
1

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.

Error and after solve

Vilify answered 16/3 at 6:47 Comment(0)
A
0

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.

Ancilin answered 25/2, 2021 at 14:19 Comment(0)
A
0

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......

Admix answered 23/3, 2021 at 11:23 Comment(0)
F
0

if you're using Yarn

yarn global add sequelize-cli --prefix /usr/local

And run

sequelize init
Flite answered 4/8, 2023 at 16:44 Comment(0)
T
0

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.

Thereabouts answered 4/10, 2023 at 7:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.