Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module [...]sequelize/dist/lib/dialects/postgres.js #141

Closed
H3RSKO opened this issue Dec 22, 2021 · 4 comments
Closed

Comments

@H3RSKO
Copy link

H3RSKO commented Dec 22, 2021

I'm trying to setup cockroachdb using this tutorial, and everything has worked so far except that when i try running the db connection through sequelize I get this error and have had no luck debugging it.

node:internal/modules/cjs/loader:473
      throw e;
      ^

Error: Cannot find module '/Users/user1/js/server/node_modules/sequelize/dist/lib/dialects/postgres.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:946:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:939:15)
    at resolveExports (node:internal/modules/cjs/loader:467:14)
    at Function.Module._findPath (node:internal/modules/cjs/loader:507:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:905:27)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/Users/user1/js/server/node_modules/sequelize-cockroachdb/source/index.js:54:25)
    at Module._compile (node:internal/modules/cjs/loader:1102:14) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/user1/js/server/node_modules/sequelize/package.json'
}

This is my package.json:

{
  "name": "@project1/server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon server.ts"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@types/express": "^4.17.13",
    "@types/node": "^16.11.12",
    "body-parser": "^1.19.1",
    "cors": "^2.8.5",
    "dotenv": "^10.0.0",
    "express": "^4.17.1",
    "passport": "^0.5.2",
    "passport-microsoft": "^0.1.0",
    "pg": "^8.7.1",
    "pg-connection-string": "^2.5.0",
    "prompt": "^1.2.0",
    "sequelize": "^6.12.1",
    "sequelize-cockroachdb": "^6.0.4"
  },
  "devDependencies": {
    "@types/passport": "^1.0.7",
    "ts-node": "^10.4.0",
    "typescript": "^4.5.4"
  }
}

I've tried deleting and reinstalling node_modules and packagelock.json and i've also cleared the npm cache, but still no luck.

Any help would be appreciated!

@mkoperator
Copy link

mkoperator commented Dec 26, 2021

Had the same issue on SvelteKit,

const PostgresDialect = require('sequelize/lib/dialects/postgres');

switching the require to reference the index file appears to work.
const PostgresDialect = require('sequelize/lib/dialects/postgres/index');

Though surely this is not the correct solution but pr created because it worked. #142

I then closed the pr, because I realized the require should be pulling in the index file by default

@mkoperator
Copy link

Did confirm this does not happen with the standard sequelize postgres driver.

@rafiss
Copy link
Contributor

rafiss commented Jan 10, 2022

I think it is caused by this upstream issue: sequelize/sequelize#13787

Can you try using sequelize 6.13.0 in your package.json?

@rafiss
Copy link
Contributor

rafiss commented Jan 11, 2022

This also required changes in this repo, made in #143

will release this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants