code-8
code-8

Reputation: 58642

Unable to resolve sequelize package

I'm trying to install sequelize-cli in my Mac OS 10.12.6.

In Terminal, I did

npm install -g sequelize-cli

I got

npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
/usr/local/bin/sequelize -> /usr/local/lib/node_modules/sequelize-cli/bin/sequelize
/usr/local/lib
└── [email protected] 

Then, I tried

sequelize model:create --name User --attributes name:string,complete:boolean

I got

Unable to resolve sequelize package in /Users/bheng/Sites/BASE

I even try with the --save as this post suggested.

npm install -g sequelize-cli --save

I got same result.

npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
/usr/local/bin/sequelize -> /usr/local/lib/node_modules/sequelize-cli/bin/sequelize
/usr/local/lib
└── [email protected] 

sequelize model:create --name User --attributes name:string,complete:boolean

Unable to resolve sequelize package in /Users/bheng/Sites/BASE

What else should I try ?

Upvotes: 19

Views: 34751

Answers (9)

Before you create the first model you need to create new file .sequelizerc and get the below code:

// .sequelizerc

const path = require('path');

module.exports = {
  config: path.resolve('./src/config', 'config.json'),
  'models-path': path.resolve('./src', 'models'),
  'seeders-path': path.resolve('./src', 'seeders'),
  'migrations-path': path.resolve('./src', 'migrations'),
};

Then you might to run your cmd.

Upvotes: 0

Anouar Bakouch
Anouar Bakouch

Reputation: 51

when downloading sequelize and sequlize-cli , you have to install both globally using -g option

npm install -g sequelize

npm install -g sequelize-cli

that's all

Upvotes: 0

MD SHAYON
MD SHAYON

Reputation: 8055

Yes. This is "normal" the CLI will try to find the sequelize package in your current working directory and/or in the node paths. So you could either install the package in your local dir or in any parent directory or in the global space.

more answers

Upvotes: 1

Jayant
Jayant

Reputation: 302

you can try this one

npm install --save-dev sequelize sequelize-cli

npx sequelize-cli init

Once you get models migrations folders, means sequelize is working.

Upvotes: 5

Nico_dev
Nico_dev

Reputation: 61

I had a similar case where when I was trying to run any sequelize command.

ie. sequelize init or sequelize --help

I would get the error:

Unable to resolve sequelize package in <my-project-directory>

None of the solutions above where helping my case but after farther digging I found this article talking about the importance of the order in which one installs dependencies.

I had installed my my development dependencies first (sequelize-cli before sequelize) and that's why it wasn't working.

Because this is a new project I just removed my yarn files and the package.json (left my other files untouched) and started over and this time I did:

  1. yarn init
  2. yarn add <my dependencies>
  3. yarn add --dev <my development dependencies>

This solved my issue.

Upvotes: 0

Rutvik Mehta
Rutvik Mehta

Reputation: 11

First you have need to install sequelize package, after then execute cli command.

Upvotes: 1

Victor Karangwa
Victor Karangwa

Reputation: 2216

I had the same issue. I installed sequelize-cli forgetting to add sequelize itself:

npm install sequelize

Upvotes: 12

vendeeshwaran Chandran
vendeeshwaran Chandran

Reputation: 1413

You will need to install sequelize globally.

npm install -g sequelize

Upvotes: 2

AbhinavD
AbhinavD

Reputation: 7282

In sequelize-cli package.json file, sequelize is mentioned as a devdependency which means it does not install it when you do npm install sequelize-cli. My guess is you have not installed sequelize itself and this is what the error says.

Unable to resolve sequelize package in /Users/bheng/Sites/BASE

install sequelize npm install --save sequelize (or global) and things should be good.

PS: Great answer on different dependencies and what they mean

Upvotes: 57

Related Questions