Error: Cannot find module 'sequelize' in the NOTE APP node js course

C:\nodeapps\emails>node server.js
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module 'sequelize'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (C:\nodeapps\emails\lib\models\index.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:722:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)

Hi madanes,

It looks as though you need to run npm install from the project folder to install the dependencies that the app needs.

2 Likes

Thank you. I ran npm install, still get the same error : Error: Cannot find module ‘sequelize’

error is:Error: Cannot find module ‘sequelize’

Is it this repo you installed from: https://github.com/sitepoint-editors/notes-board ?

I don’t have access to the course, but let’s take this from the top.

First read the readme file, which says:

Clone repo
Run npm install
Run npm run start:dev
Visit http://localhost:3000/

Then clone the repository:

> git clone https://github.com/sitepoint-editors/notes-board
Cloning into 'notes-board'...
remote: Enumerating objects: 38, done.
remote: Total 38 (delta 0), reused 0 (delta 0), pack-reused 38
Unpacking objects: 100% (38/38), done.

And install

> cd notes-board
> npm install
npm WARN deprecated joi@10.6.0: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated boom@4.3.1: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.

> node-sass@3.13.1 install C:\Users\paulm\Documents\sitepoint\node-course-note-app\notes-board\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-64_binding.node":

HTTP error 404 Not Found
...

The upgrades I can deal with later, after I get things working, but the node-sass issue seems to be a real problem.

Troubleshooting

Is my antivirus interfering with things?

  • delete node_modules, disable antivirus, try again - no, that wasn’t the problem.

I try to install the dependencies separately, using the list in package.json

> npm install dotenv@2.0.0
...
> npm install hapi@16.0.2
...
> npm install hoek@4.1.0
...
> npm install inert@4.1.0
...
> npm install moment@2.17.1
...
> npm install pug@2.0.0-beta6
...
> npm install sequelize@3.28.0
...
> npm install slug@0.9.1
...

All of those install.

> npm install sqlite3@3.1.8
...

That one has trouble, with installing node-sass

Can I install node-sass separately? The download seems to work this way, but I don’t have python2
Going to the node-sass webpage, I see that Windows users need to install some prerequisites first from an administrator command prompt. That gives its own error about how the Visual Studio build tools could not be installed.

Trying to reinstall node-sass without that, I’m told that msbuild is missing.

Installing the prerequisites once again, it tells me about the C:\Users\paulm\.windows-build-tools folder which I find has a vs_BuildTools.exe file, and when I run that I see that I must update the installer. That gives me an interface and because the build prerequisites page gives another option to install the c++ build environment, I choose from the updated build tools to install the c++ build tools.

Time to cleanup again by deleting node_modules, and attempting to install.

> npm install

node-sass still has trouble downloading and installing as a part of the notes-board install.
Can I install node-sass separately, then install notes-board? No, for sqlite has trouble installing.
Does sqlite 3.1.8 install just by itself? No.
Can any sqlite install just by itself? Yes, but it just installs version 3.0.0
Can I install the most recent version?

> npm install sqlite3@4.0.6

The sqlite3 install also wants me to to an audit fix, so I’d better do that, but not yet.
The rest of the install needs to be done now.

> npm install
...
> npm audit fix
...

And the remaining issue that the audit tells us about is about sequalize

Fixing the sequalize issue

I install it as it requests:

> npm install sequelize@4.42.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ sequelize@4.42.0
added 5 packages from 37 contributors, removed 2 packages, updated 6 packages and audited 7249 packages in 14.035s
found 0 vulnerabilities

which works well.

The audit shows no further issues.

Summary

So what do we need to do before installing notes-board?

  • Install prerequisites
    • Install c++ build tools from the C:\Users\yourname\.windows-build-tools\ folder
  • Install version 4 of sqlite with npm install sqlite3@4.0.6
  • Install notes-board with npm install
  • Cleanup with npm audit fix
    • install sequelize with npm install sequelize@4.42.0

And I can now carry on with the notes install by running the server and visiting the web local webpage.

1 Like

Is there an easier way? Up until now I’ve been installing from a user account.

Deleting node_modules to start from afresh, and using an Administrator command prompt in the notes-board folder, running npm install results in immediate success.

I haven’t tested by first uninstalling the c++ build tools. You might need to go to C:\Users\yourname\.windows-build-tools\ and install them from there before trying again.

madanes - based on the success here, you might want to try the administrator command prompt install instead.

1 Like

Update!

The efforts above were for the old repo.

The new repo is found at https://github.com/sitepoint-editors/note-board-email-course

> git clone https://github.com/sitepoint-editors/note-board-email-course
Cloning into 'note-board-email-course'...
remote: Enumerating objects: 53, done.
remote: Total 53 (delta 0), reused 0 (delta 0), pack-reused 53
Unpacking objects: 100% (53/53), done.

Then install

> cd note-board-email-course

> npm install

...

Then run the server

> node server.js
Executing (default): CREATE TABLE IF NOT EXISTS `Notes` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `date` DATETIME, `title` VARCHAR(255), `slug` VARCHAR(255), `description` VARCHAR(255), `content` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL);
Executing (default): PRAGMA INDEX_LIST(`Notes`)
Server running at: http://DESKTOP-EHKALM4:3000
Executing (default): SELECT `id`, `date`, `title`, `slug`, `description`, `content`, `createdAt`, `updatedAt` FROM `Notes` AS `Note` ORDER BY `Note`.`date` DESC;

And you can now visit localhost:3000 to check the notes app.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.