Reputation: 58642
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
Reputation: 1
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
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
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.
Upvotes: 1
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
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:
yarn init
yarn add <my dependencies>
yarn add --dev <my development dependencies>
This solved my issue.
Upvotes: 0
Reputation: 11
First you have need to install sequelize package, after then execute cli command.
Upvotes: 1
Reputation: 2216
I had the same issue. I installed sequelize-cli
forgetting to add sequelize
itself:
npm install sequelize
Upvotes: 12
Reputation: 1413
You will need to install sequelize globally.
npm install -g sequelize
Upvotes: 2
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