5

I've install (fresh install) using nodejs and npm, then install sequelize-cli and module as per instruction on tutorial of sequelize http://docs.sequelizejs.com/manual/tutorial/migrations.html#installing-cli

But when wan't to do anything with sequelize, it return an error like below :

    me@u64:~/project/manztihagi$ sequelize
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'sequelize'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/lib/node_modules/sequelize-cli/lib/helpers/model-helper.js:7:18)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at /usr/lib/node_modules/sequelize-cli/lib/helpers/index.js:18:52
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/usr/lib/node_modules/sequelize-cli/lib/helpers/index.js:17:4)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/lib/node_modules/sequelize-cli/lib/commands/init.js:7:16)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
me@u64:~/project/manztihagi$ 

Search another solution until reinstall the packages still not luck.

How to resolve this error ?

me@u64:~/project/manztihagi$ ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.1.3
Node: 10.9.0
OS: linux x64
Angular: undefined
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.3 (cli-only)
@angular-devkit/core         0.7.3 (cli-only)
@angular-devkit/schematics   0.7.3 (cli-only)
@schematics/angular          0.7.3 (cli-only)
@schematics/update           0.7.3 (cli-only)
rxjs                         6.2.2

me@u64:~/project/manztihagi$ node -v
v10.9.0
me@u64:~/project/manztihagi$ npm -v
6.2.0
me@u64:~/project/manztihagi$ 

4 Answers 4

12

Looks like you install the cli in global node modules. You should also install the sequelize package along with sequelize-cli

if do it globally

npm install -g sequelize-cli
npm install -g sequelize

if do it locally

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

Hope it can solve your issue

1
  • I'm already try your solution and solve my issue, but the other hand, from the other tutorial that guide the sequelize-cli shall install as global module and sequelize as local module but the error appear. I'm trying on other machine, sequelize-cli as global and sequelize as local both of sequelize can run well ... Not sure what happened on my this machines error
    – ManzTIHAGI
    Commented Aug 21, 2018 at 6:52
4
Error: Cannot find module 'sequelize'

I had the same problem, but it was caused by wrong name of module.

  • correct form is: require('sequelize')
  • wrong is: require('Sequelize')

I was working on windows and trying to run code on better system ;)

hope this might be helpfull, GL

3

I had a similar error:

Error: Cannot find module 'sequelize/types/lib/operators'

which I found was caused by my Visual Studio Code 'helping out' by adding in:

const { substring } = require("sequelize/types/lib/operators");

I deleted this line from the top of my code, and problem went away.

Since google sent me to this similar question, I thought I would share my different solution to a different problem:

What happened?

Visual Studio Code tries to help out by automatically adding imports as you type, and when I typed this line of code:

enumSingular = enumPlural.substring(0, enumPlural.length - 1);

VS Code thought it needed to add the substring from Sequelize. I was trying to use the substring() method of the JavaScript String prototype, but I did not notice the auto-add.

1
  • Yes you were right! VS code was the culprit. It has added an import to something which i accidently typed and deleted. Thank you. Commented Jan 12, 2022 at 23:09
2

You should install sequelize and sequelize-cli with same option. Ex:

npm install -g sequelize-cli npm install -g sequelize

GL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.