JavaScript Install and Use Sequelize CLI

Running npx sequelize init isn't working

Whenever I run npx sequelize init, it says

npx: installed 19 in ___s
command not found: sequelize

if I run it in C:\Users\babyoscar\Downloads\project-files or if I run it in C:\Users\babyoscar\Downloads\project-files\project-files or if I run it in C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project . If I go to C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express, it says:

Unable to resolve sequelize package in C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express

. Can someone help? Thanks.

8 Answers

James Hanley
seal-mask
.a{fill-rule:evenodd;}techdegree
James Hanley
Full Stack JavaScript Techdegree Student 11,773 Points

I got it to work by deleting my node_modules folder, and then in package.json i deleted the dependency list and installed them manually without specifying a version. This way npm installs the correct and current versions, and my dependencies entry ended up looking like this when i was done, and, i am able to npm start. "dependencies": { "cookie-parser": "^1.4.5", "debug": "^4.3.1", "express": "^4.17.1", "http-errors": "^1.8.0", "morgan": "^1.10.0", "node": "^15.4.0", "nodemon": "^2.0.7", "pug": "^3.0.0", "sequelize": "^5.22.3", "sequelize-cli": "^5.5.1", "sqlite3": "^5.0.0" }

Michael Kobela
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Kobela
Full Stack JavaScript Techdegree Graduate 19,535 Points

I would start by checking that sequelize is installed correctly on your system. npm can be used to investigate installed packages:

  1. Use this to see global packages, if you installed it globally:

npm list -g --depth=0

You should see something like this, check that sequelize is in the list.

├── babel-node@0.0.1-security ├── reactjs-express-generator@1.5.0 ├── sequelize@6.3.5

  1. Use this to see local packages, if you installed it locally to your project:

This should be ran in the folder containing node_modules.

npm list --depth=0

├── sequelize@6.3.5

  1. If the package is installed, try uninstalling it and reinstalling since it's not working.

For global install:

npm uninstall -g sequelize npm install -g sequelize

For local install:

npm uninstall sequelize npm install sequelize

  1. Now try using this to see if it's working:

npx sequelize init

I ran npm list --depth=0, and it threw these errors:

+-- UNMET DEPENDENCY cookie-parser@~1.4.4
+-- UNMET DEPENDENCY debug@~2.6.9
+-- UNMET DEPENDENCY express@^4.17.1
+-- UNMET DEPENDENCY http-errors@^1.6.3
+-- UNMET DEPENDENCY moment@^2.24.0
+-- UNMET DEPENDENCY morgan@~1.9.1
+-- UNMET DEPENDENCY nodemon@^1.19.2
+-- UNMET DEPENDENCY pug@^2.0.4
+-- UNMET DEPENDENCY sequelize@^5.18.4
+-- sequelize-cli@5.5.1
`-- UNMET DEPENDENCY sqlite3@^4.1.0

npm ERR! missing: cookie-parser@~1.4.4, required by blog@1.0.0
npm ERR! missing: debug@~2.6.9, required by blog@1.0.0
npm ERR! missing: express@^4.17.1, required by blog@1.0.0
npm ERR! missing: http-errors@^1.6.3, required by blog@1.0.0
npm ERR! missing: moment@^2.24.0, required by blog@1.0.0
npm ERR! missing: morgan@~1.9.1, required by blog@1.0.0
npm ERR! missing: nodemon@^1.19.2, required by blog@1.0.0
npm ERR! missing: pug@^2.0.4, required by blog@1.0.0
npm ERR! missing: sequelize@^5.18.4, required by blog@1.0.0
npm ERR! missing: sqlite3@^4.1.0, required by blog@1.0.0

How do I fix this?

Michael Kobela
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Kobela
Full Stack JavaScript Techdegree Graduate 19,535 Points

Just did a quick google and found this:

https://stackoverflow.com/questions/22620352/npm-windows-install-globally-results-in-npm-err-extraneous

Possibly means that your package.json file does not have an entry for the modules http-errors, debug and so on, even thought the packages might be installed globally. So check you .json file and add them as needed.

Use:

npm install http-errors

and check that it was added to the package.json file.

I'm pretty sure it's in my package.json file, here's the code in my package.json file:

{
  "name": "blog",
  "version": "1.0.0",
  "description": "A simple blog application",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "cookie-parser": "~1.4.4",
    "debug": "~2.6.9",
    "express": "^4.17.1",
    "http-errors": "^1.6.3",
    "moment": "^2.24.0",
    "morgan": "~1.9.1",
    "nodemon": "^1.19.2",
    "pug": "^2.0.4",
    "sequelize": "^5.18.4",
    "sequelize-cli": "^5.5.1",
    "sqlite3": "^4.1.0"
  }
}
Michael Kobela
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Kobela
Full Stack JavaScript Techdegree Graduate 19,535 Points

I have never seen this before, so maybe try deleting you node_modules folder and run:

npm install

again. This will reinstall everything. Seems like something got corrupted.

Okay, now when I run npm install in C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express, it throws a bunch of errors:

npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to 
chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated core-js@2.6.12: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})    

npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json.1023590119
npm ERR! dest C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json   
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json.1023590119' -> 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json'
npm ERR!  [OperationalError: EPERM: operation not permitted, rename 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json.1023590119' -> 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, rename 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json.1023590119' -> 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\graceful-fs\package.json'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     path: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\graceful-fs\\package.json.1023590119',
npm ERR!     dest: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\graceful-fs\\package.json'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\graceful-fs\\package.json.1023590119',
npm ERR!   dest: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\graceful-fs\\package.json',
npm ERR!   parent: 'using-sequelize-orm-with-express'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the 
npm ERR! permissions of the file and its containing directories, or try running    
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\babyoscar\AppData\Roaming\npm-cache\_logs\2021-01-26T01_02_13_896Z-debug.log
Michael Kobela
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Kobela
Full Stack JavaScript Techdegree Graduate 19,535 Points

I think you system is possessed by an evil spirt, only kidding :-) I have the same exact package.json for the project here, I delete my node_modules and it all installs ok.

Your's is complaining the some modules are depreciated and not playing well with others, but these modules are not dependencies in your package.json, so must be dependent some other way.

What version of npm and node do you have, mine is:

using-sequelize-orm-with-express mkobela$ node --version v12.18.4

Michaels-MacBook-Pro:using-sequelize-orm-with-express mkobela$ npm --version 6.14.6

Not sure if that could be causing it.

I did look at you package.json, the same as mine, but the version of files are old, see recent version listed below next to current version:

"dependencies": {
    "cookie-parser": "~1.4.4",  1.4.5
    "debug": "~2.6.9",      4.31
    "express": "^4.17.1",       4.17.1
    "http-errors": "^1.6.3",    1.8.0
    "moment": "^2.24.0",        2.29.1
    "morgan": "~1.9.1",     1.10.0
    "nodemon": "^1.19.2",       2.0.7
    "pug": "^2.0.4",                3.0.0
    "sequelize": "^5.18.4",     6.4.0
    "sequelize-cli": "^5.5.1",  6.2.0
    "sqlite3": "^4.1.0"     5.0.1
  }

Okay, my node is v14.15.1, and my npm is v6.14.8. I changed my version numbers in the package.json file, just to double check, here is the code:

{
  "name": "blog",
  "version": "1.0.0",
  "description": "A simple blog application",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "cookie-parser": "~1.4.5",
    "debug": "~4.3.1",
    "express": "^4.17.1",
    "http-errors": "^1.8.0",
    "moment": "^2.29.1",
    "morgan": "~1.10.0",
    "nodemon": "^2.0.7",
    "pug": "^3.0.0",
    "sequelize": "^6.4.0",
    "sequelize-cli": "^6.2.0",
    "sqlite3": "^5.0.1"
  }
}

, and it works when I run npm install, but it still says

npx: installed 19 in 9.137s
command not found: sequelize

when I run npx sequelize init in C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express. When I delete the node_modules folder, then run npm install, I have the error again:

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported       
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.1 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})     

npm ERR! code EPERM
npm ERR! syscall rename
npm ERR! path C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json.743013971
npm ERR! dest C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json     
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json.743013971' -> 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json'
npm ERR!  [OperationalError: EPERM: operation not permitted, rename 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json.743013971' -> 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, rename 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json.743013971' -> 'C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express\node_modules\forwarded\package.json'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'rename',
npm ERR!     path: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\forwarded\\package.json.743013971',
npm ERR!     dest: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\forwarded\\package.json'
npm ERR!   },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\forwarded\\package.json.743013971',
npm ERR!   dest: 'C:\\Users\\babyoscar\\Downloads\\project-files\\project-files\\1- Introducing the Project\\using-sequelize-orm-with-express\\node_modules\\forwarded\\package.json',
npm ERR!   parent: 'using-sequelize-orm-with-express'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the 
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\babyoscar\AppData\Roaming\npm-cache\_logs\2021-01-26T19_24_59_308Z-debug.log
James Hanley
seal-mask
.a{fill-rule:evenodd;}techdegree
James Hanley
Full Stack JavaScript Techdegree Student 11,773 Points

I use windows and i did not have to set a path when using npm install sequalize, i did not try the npx method, the npm install method worked for me. Also, i noticed that my dependency list in the json has sequalize as an earlier version, "sequelize": "^5.22.3" and babyoscar has 6.4 as a version. I had a lot of trouble with "versions" in this course. Lots of deprecation errors, or library not supported errors if you use the version the course tells you to. Try to follow my earlier post where I deleted my dependency list and installed using npm manually, each package. That worked for me, also, maybe the version of sequalize does not exists? Maybe try setting your json file like mine is in my earlier post?

Michael Kobela
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Michael Kobela
Full Stack JavaScript Techdegree Graduate 19,535 Points

@babyosca had issues with the old versions as well. I just updated to the latest and npx sequelize init still worked here. I could not install sqlite3@5.0.1 so used 5.0.0

Thanks! Finally worked! I installed each of the package's manually with npm install <package> --save, and running npx sequelize init in C:\Users\babyoscar\Downloads\project-files\project-files\1- Introducing the Project\using-sequelize-orm-with-express worked!