ManzTIHAGI
ManzTIHAGI

Reputation: 146

Error cannot find module 'sequelize'

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$ 

Upvotes: 5

Views: 45235

Answers (4)

NULL pointer
NULL pointer

Reputation: 1377

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.

Upvotes: 3

nuEn
nuEn

Reputation: 81

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

Upvotes: 4

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

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

GL.

Upvotes: 2

deerawan
deerawan

Reputation: 8443

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

Upvotes: 12

Related Questions