Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to solve "sequelize: command not found"?

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?

like image 748
Hejhejhej123 Avatar asked Jun 09 '26 01:06

Hejhejhej123


2 Answers

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
like image 170
Hejhejhej123 Avatar answered Jun 11 '26 14:06

Hejhejhej123


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]
like image 33
LEQADA Avatar answered Jun 11 '26 16:06

LEQADA