how to solve "sequelize: command not found"?
Asked Answered
F

6

8

This is so frustrating.. I am trying to install sequalize for node.js. I installed it locally with success, but I cant install it globally (I am getting permission denied errors for:

 \'../lib/node_modules/sequelize-cli/lib/sequelize\').

I actually don't really want it globally installed, but when have it locally and should configure and initialize the sequelize module (by typing sequelize init:models & sequelize init:config in terminal) I get the following error:

-bash: sequelize: command not found

So I did my homework and found out that the command not found error could be solved with globally install (-bash: sequelize: command not found) and to fix the error in enabling globally install I changed my user access (Error: EACCES: permission denied, access '/usr/local/lib/node_modules' react), but this didnt do the trick, I still getting permission denied.

So my question is how could I run sequelize init:models & sequelize init:config in terminal without getting command not found?

Ferroconcrete answered 23/9, 2019 at 17:22 Comment(4)
To install packages globally, most of the times you need root privileges so you need to use sudo and insert your password $sudo npm install -g sequelize.Flavin
It worked! I used sudo on both npm install -g sequelize and npm install sequelize-cli and then it worked. thanks!Ferroconcrete
Possible duplicate of -bash: sequelize: command not foundWally
@Flavin quick tip: if you have to use sudo when you're using npm, something is wrong. I recommend you get that fixed quickly. That is super dangerous. If someone put a script in their "postinstall" for rm -rf /, it runs automatically after installation, and you've just run it with sudo and given it permission to delete your entire hard drive.Wally
F
9

The answer for my problem was solved with installing it global with the help of sudo as vitamadio said in the comment. So the answear was to install it this way:

sudo npm install -g sequelize 

and then:

sudo npm i -g sequelize-cli
Ferroconcrete answered 23/9, 2019 at 20:16 Comment(0)
C
6

You need to install

npm install --save sequelize
npm install --save sequelize-cli

And then according to documentation you can run the CLI. No need to install it globally.

$ npx sequelize --help

Sequelize CLI [Node: 10.0.0, CLI: 5.5.1, ORM: 5.19.0]

sequelize [command]

Commands:
  sequelize db:migrate                        Run pending migrations
  sequelize db:migrate:schema:timestamps:add  Update migration table to have timestamps
  sequelize db:migrate:status                 List the status of all migrations
  sequelize db:migrate:undo                   Reverts a migration
  sequelize db:migrate:undo:all               Revert all migrations ran
  sequelize db:seed                           Run specified seeder
  sequelize db:seed:undo                      Deletes data from the database
  sequelize db:seed:all                       Run every seeder
  sequelize db:seed:undo:all                  Deletes data from the database
  sequelize db:create                         Create database specified by configuration
  sequelize db:drop                           Drop database specified by configuration
  sequelize init                              Initializes project
  sequelize init:config                       Initializes configuration
  sequelize init:migrations                   Initializes migrations
  sequelize init:models                       Initializes models
  sequelize init:seeders                      Initializes seeders
  sequelize migration:generate                Generates a new migration file   [aliases: migration:create]
  sequelize model:generate                    Generates a model and its migration  [aliases: model:create]
  sequelize seed:generate                     Generates a new seed file             [aliases: seed:create]

Options:
  --help     Show help                                                                           [boolean]
  --version  Show version number                                                                 [boolean]
Chat answered 23/9, 2019 at 17:55 Comment(4)
I have done that, it still says "sequelize: command not found”Ferroconcrete
what is the output of this command npm ls | grep sequelize ?Chat
And did you try to run it like this npx sequelize init:models?Chat
Hi, thanks a lot for your help, I solved it with using sudo on both npm install -g sequelize and npm install sequelize-cli.Ferroconcrete
S
4

You need to install as following:

npm install --save sequelize
npm install --save sequelize-cli

Also install npx if you don't have it then Initialize sequelize:

npx sequelize init
Shelba answered 24/11, 2020 at 10:1 Comment(0)
P
0

do as same below It should be work fine npm install --save sequelize npm install --save sequelize-cli npx sequelize init

Pot answered 4/8, 2021 at 4:0 Comment(1)
1.npm install --save sequelize 2.npm install --save sequelize-cli 3.npx sequelize initPot
U
0

Try to run this command in your terminal.

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

Usually answered 23/3, 2022 at 8:21 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Polystyrene
A
0

It worked for me like this. First run:

npm install -g sequelize-auto

Then I got the following error (Error: Please install mysql2 package manually) and I solved it by running:

npm install mysql2 -g

And with that I'm done, I hope it helps someone.

Adjoining answered 4/9 at 16:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.