You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reacted by Ante Lucic, Cory Simmons, Asad Sahi, Peter Galkaev, Ray Toal, Jorge Cuevas, manuelccosta, Elliot Lewis, Thomas Kaul, Mohamed Saleh and 15 more
Reacted by Justin Pincar, Grigorii K. Shartsev, Bui Cong Loi, Nishant Dani, Alexander Drozdov, Kevin UNFRICHT, Genuabath, Tebogo Nkomondo, Florian Schmidt, Jaid and 55 more
This needs to be reopened, This is an issue with how sequelize conditionally requires its dependencies. If I can't just yarn add sequelize and have it work then it's a problem on your end. I'm using mysql, not postgress so ideally the code that attempts require('pg-hstore') should never had ran. I didn't use to have this issue so its due to a regression.
Reacted by Matthew, Mark Tompkins, Bruno Siqueira, Ante Lucic, Florian Nagel, Byron Tuckett, Justin Pincar, Ali Faris, Wyatt Kirby, Jorge Cuevas and 121 more
This needs to be reopened, This is an issue with how sequelize conditionally requires its dependencies. If I can't just yarn add sequelize and have it work then it's a problem on your end. I'm using mysql, not postgress so ideally the code that attempts require('pg-hstore') should never had ran. I didn't use to have this issue so its due to a regression.
Even though i'm using Postgres as my dialect, it doesn't seem like Tedious is a conditional import.
Workaround by just installing Tedious but it is a little tedious ;) having to bundle unnecessary modules
Webpack build warnings and errors:
WARNING in ./node_modules/sequelize/lib/dialects/mssql/connection-manager.js
Module not found: Error: Can't resolve 'tedious' in '/Users/louiskw/Documents/GitHub/WhoTargetsMe-Backend/node_modules/sequelize/lib/dialects/mssql'
@ ./node_modules/sequelize/lib/dialects/mssql/connection-manager.js 23:19-37
@ ./node_modules/sequelize/lib/dialects/mssql/index.js
@ ./node_modules/sequelize/lib/sequelize.js
@ ./node_modules/sequelize/index.js
@ ./src/db/models.js
@ ./src/handler.js
WARNING in ./node_modules/sequelize/lib/dialects/mysql/connection-manager.js
Module not found: Error: Can't resolve 'mysql2' in '/Users/louiskw/Documents/GitHub/WhoTargetsMe-Backend/node_modules/sequelize/lib/dialects/mysql'
@ ./node_modules/sequelize/lib/dialects/mysql/connection-manager.js 33:19-36
@ ./node_modules/sequelize/lib/dialects/mysql/index.js
@ ./node_modules/sequelize/lib/sequelize.js
@ ./node_modules/sequelize/index.js
@ ./src/db/models.js
@ ./src/handler.js
WARNING in ./node_modules/sequelize/lib/dialects/sqlite/connection-manager.js
Module not found: Error: Can't resolve 'sqlite3' in '/Users/louiskw/Documents/GitHub/WhoTargetsMe-Backend/node_modules/sequelize/lib/dialects/sqlite'
@ ./node_modules/sequelize/lib/dialects/sqlite/connection-manager.js 27:19-37
@ ./node_modules/sequelize/lib/dialects/sqlite/index.js
@ ./node_modules/sequelize/lib/sequelize.js
@ ./node_modules/sequelize/index.js
@ ./src/db/models.js
@ ./src/handler.js
WARNING in ./node_modules/sequelize/lib/sequelize.js
374:61-74 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/sequelize/lib/dialects/mssql/connection-manager.js
21:19-62 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/sequelize/lib/dialects/postgres/connection-manager.js
21:16-59 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/sequelize/lib/dialects/mysql/connection-manager.js
31:19-62 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/sequelize/lib/dialects/sqlite/connection-manager.js
25:19-62 Critical dependency: the request of a dependency is an expression
ERROR in ./node_modules/sequelize/lib/dialects/mssql/query.js
Module not found: Error: Can't resolve 'tedious' in '/Users/louiskw/Documents/GitHub/WhoTargetsMe-Backend/node_modules/sequelize/lib/dialects/mssql'
@ ./node_modules/sequelize/lib/dialects/mssql/query.js 10:14-32
@ ./node_modules/sequelize/lib/dialects/mssql/index.js
@ ./node_modules/sequelize/lib/sequelize.js
@ ./node_modules/sequelize/index.js
@ ./src/db/models.js
@ ./src/handler.js
ERROR in ./node_modules/pg/lib/native/client.js
Module not found: Error: Can't resolve 'pg-native' in '/Users/louiskw/Documents/GitHub/WhoTargetsMe-Backend/node_modules/pg/lib/native'
@ ./node_modules/pg/lib/native/client.js 10:13-33
@ ./node_modules/pg/lib/native/index.js
@ ./node_modules/pg/lib/index.js
@ ./node_modules/sequelize/lib/dialects/postgres/connection-manager.js
@ ./node_modules/sequelize/lib/dialects/postgres/index.js
@ ./node_modules/sequelize/lib/sequelize.js
@ ./node_modules/sequelize/index.js
@ ./src/db/models.js
@ ./src/handler.js
Reacted by Brandon Maushund, Patrick Lienau, Justin Pincar, Tamanna Makkar, Bartosz Klukaczewski, pumpkinheadgiant, Kirill Potekhin, Ramil Yanbulatov, Sam Garson, Derek Lu and 31 more
Reacted by Michał Zalewski, oda nabunaga, Aaron B, Emiel Van Severen, Md Mazedul Islam Khan, Ben Zhang and Lightbender255
Reacted by Alexander Drozdov, Brian Schaper, Rasmus Høhndorf Hummelmose, Laszlo, esdeseace, Robin Thomas, Benjamin Hall, Andrew Ferreira, Ricky and ktrenkov
WARNING in ./node_modules/sequelize/lib/sequelize.js 374:61-74 Critical dependency: the request of a dependency is an expression
Inspirated from comment here angular/angular#11580 (comment) I rewrite this piece of code for sequelize, and warnings dissapeared:
new webpack.ContextReplacementPlugin(
/Sequelize(\\|\/)/,
path.resolve(__dirname, '../src')
)
If anyone find better workaround, please write a comment. Also I agree that this issue should be reopened , as build bug using webpack.
Reacted by Dmitriy, Michał Zalewski, Peter Galkaev, Lee Jacobson, Bruno Siqueira, Matt Kraatz, Sarah Silva, Sumit Kushwaha, Liu Renhao, Alexandru Chichinete and 5 more
Reacted by Alexandru Chichinete, Simple Code Merchant and gedune
Explanation:
AstroJS uses Vite under the hood. This way it will be excluded from the build(?) process. I assume it tries to rebuild/treeshaking the dependencies. It works for me.
I don't know what a webpack is, but I have been getting this issue when trying to make Sequelize work with npm
And the funny thing is that Sequelize launches for me just fine if I use "node" to launch it.
You're using parcel which is another bundler. From a quick Google search, I think using ignoreNodeModules could be used to ignore sequelize although I have no experience with using parcel
I don't know what a webpack is, but I have been getting this issue when trying to make Sequelize work with npm
And the funny thing is that Sequelize launches for me just fine if I use "node" to launch it.
You're using parcel which is another bundler. From a quick Google search, I think using ignoreNodeModules could be used to ignore sequelize although I have no experience with using parcel
I already solved my issue. Turns out I just didn't have pg-hstore installed.
I had the same issue with NextJS 13, I've solved it by adding 'sequelize' to the 'next.config.mjs' under the 'experimental' label: const nextConfig = { output: 'standalone', experimental: { appDir: true, serverComponentsExternalPackages: ['sequelize'] } } module.exports = nextConfig;
Reacted by Kyran Butler, Tim Schramme, devenode, Daniel González, chenbrian, Serhii N., JoeLeeRob and Lean
Reacted by Bruno Quaresma, Daniel González, Herbert Verdida and Lean
I had the same issue with NextJS 13, I've solved it by adding 'sequelize' to the 'next.config.mjs' under the 'experimental' label: const nextConfig = { output: 'standalone', experimental: { appDir: true, serverComponentsExternalPackages: ['sequelize'] } } module.exports = nextConfig;
Sorry to bring this back up, but I'm getting this same error when trying to run sam build for an AWS lambda. Using Node/TS.
I'm just trying to use sequelize with mysql2.
I had the same issue with NextJS 13, I've solved it by adding 'sequelize' to the 'next.config.mjs' under the 'experimental' label: const nextConfig = { output: 'standalone', experimental: { appDir: true, serverComponentsExternalPackages: ['sequelize'] } } module.exports = nextConfig;
Same situation and this works for me. I just wonder why this work, can anyone explain it?
Sorry to bring this back up, but I'm getting this same error when trying to run sam build for an AWS lambda. Using Node/TS. I'm just trying to use sequelize with mysql2.
I have same happened to me when trying use with mysql and node/ts . This occurs when i try to test my serverless function with sls offline
Sorry to bring this back up, but I'm getting this same error when trying to run sam build for an AWS lambda. Using Node/TS. I'm just trying to use sequelize with mysql2.
I have same happened to me when trying use with mysql and node/ts . This occurs when i try to test my serverless function with sls offline
I have solved it simply just putting 'pg-hstore' in exclude of esbuild.
Config below is my serverless.ts
@ephys Would it be worth at least mentioning this in the Getting Started page? It seems like a lot of people have ended up here trying to find out how to fix the problem, so it's maybe not as intuitive as you think…
Edit: even after getting Vite to start, when using Sequelize 7 with SvelteKit, it still doesn't actually work properly:
I have precisely no idea how to fix this. IMHO, this code shouldn't even be trying to import @sequelize/mariadb:
Activity
janmeier commentedon Apr 12, 2017
pg-hstore is only installed in dev (when you run
npm installdirectly in the sequelize directory) - In which case are you seeing this?dlimkin commentedon Apr 24, 2017
When I build my project with webpack.
janmeier commentedon Apr 25, 2017
https://github.com/sequelize/sequelize/search?q=webpack&type=Issues&utf8=%E2%9C%93
rozzzly commentedon May 21, 2017
This needs to be reopened, This is an issue with how
sequelizeconditionallyrequires its dependencies. If I can't justyarn add sequelizeand have it work then it's a problem on your end. I'm usingmysql, notpostgressso ideally the code that attemptsrequire('pg-hstore')should never had ran. I didn't use to have this issue so its due to a regression.alucic commentedon Jun 19, 2017
@janmeier Can you reopen this issue?
It is impossible to bundle up code using webpack without installing all dependencies that are required.
Were deploying single bundled up file to the production servers and here all data types are being required which breaks our build since not all of the required dependencies are installed
https://github.com/sequelize/sequelize/blob/v4.1.0/lib/data-types.js#L842-L845
janmeier commentedon Jun 20, 2017
Hstore is only loaded, if you actually use it.
sequelize/lib/dialects/postgres/data-types.js
Line 363 in 584b6f7
I'm sure webpack can be configured to ignore some modules, but that is outside the scope of sequelize
stunningpixels commentedon Aug 8, 2017
Even though i'm using Postgres as my dialect, it doesn't seem like Tedious is a conditional import.
Workaround by just installing Tedious but it is a little tedious ;) having to bundle unnecessary modules
Webpack build warnings and errors:
Maushundb commentedon Aug 26, 2017
Same issue as @stunningpixels, would love to have this reopened as well.
EdByrnee commentedon Sep 3, 2017
Same issue
corysimmons commentedon Sep 20, 2017
@janmeier Re-open until there's a solid workaround.
louisremi commentedon Sep 20, 2017
EDIT: my previous answer was wrong. To fix this problem, the easiest solution is to configure Webpack to make all your node_modules
externals:see https://webpack.js.org/configuration/externals/
and http://jlongster.com/Backend-Apps-with-Webpack--Part-I
corysimmons commentedon Sep 20, 2017
Anyone in thread happen to know if Browserify/Rollup/etc suffer from this?
kareljuricka commentedon Oct 9, 2017
Similar problem here when build with webpack. Using webpack-node-externals to make node_modules externals but does not help.
First possible workaround I found to build without errors is install all dialect libraries.
Second possible workaround is add array ["pg", "sqlite3", "tedious", "pg-hstore"] to webpack externals, for me:
externals: [nodeExternals(), ["pg", "sqlite3", "tedious", "pg-hstore"]]But warnings still remains - for example:
WARNING in ./node_modules/sequelize/lib/sequelize.js 374:61-74 Critical dependency: the request of a dependency is an expressionInspirated from comment here angular/angular#11580 (comment) I rewrite this piece of code for sequelize, and warnings dissapeared:
If anyone find better workaround, please write a comment. Also I agree that this issue should be reopened , as build bug using webpack.
26 remaining items
Robert-Ernst commentedon Apr 13, 2023
In AstroJS this is the intended way of solving this:
In the root folder create a file with the name
astro.config.mjsExplanation:
AstroJS uses Vite under the hood. This way it will be excluded from the build(?) process. I assume it tries to rebuild/treeshaking the dependencies. It works for me.
Source:
WikiRik commentedon Apr 15, 2023
You're using parcel which is another bundler. From a quick Google search, I think using
ignoreNodeModulescould be used to ignore sequelize although I have no experience with using parcelSamuelBucher commentedon Apr 15, 2023
I already solved my issue. Turns out I just didn't have pg-hstore installed.
manuchis commentedon May 1, 2023
I had the same issue with NextJS 13, I've solved it by adding 'sequelize' to the 'next.config.mjs' under the 'experimental' label:
const nextConfig = { output: 'standalone', experimental: { appDir: true, serverComponentsExternalPackages: ['sequelize'] } } module.exports = nextConfig;danielgzp commentedon May 15, 2023
This totally worked for me.
tjgragg commentedon May 30, 2023
Sorry to bring this back up, but I'm getting this same error when trying to run
sam buildfor an AWS lambda. Using Node/TS.I'm just trying to use sequelize with mysql2.
WeiGrand commentedon Jun 3, 2023
Same situation and this works for me. I just wonder why this work, can anyone explain it?
EnkhAmar commentedon Jun 15, 2023
I have same happened to me when trying use with mysql and node/ts . This occurs when i try to test my serverless function with
sls offlineEnkhAmar commentedon Jun 16, 2023
I have solved it simply just putting 'pg-hstore' in exclude of esbuild.
Config below is my serverless.ts
Jan-T-Berg commentedon Jun 16, 2023
I make a new Next13 Application with src and app folder.
install sequelize
connect to mysql2 and get
Module not found: Can't resolve 'pg-hstore'
It works with:
const nextConfig = { output: 'standalone', experimental: { appDir: true, serverComponentsExternalPackages: ['sequelize'] } } module.exports = nextConfig;
but its bad for our CI/CD. Pls fix it
ephys commentedon Jun 16, 2023
There is nothing to fix on our end. Marking these packages as external is exactly what you need to do. They are not designed to be bundled.
unikitty37 commentedon Aug 11, 2024
@ephys Would it be worth at least mentioning this in the Getting Started page? It seems like a lot of people have ended up here trying to find out how to fix the problem, so it's maybe not as intuitive as you think…
Edit: even after getting Vite to start, when using Sequelize 7 with SvelteKit, it still doesn't actually work properly:
I have precisely no idea how to fix this. IMHO, this code shouldn't even be trying to import
@sequelize/mariadb:vite.config.ts:
RLain commentedon Oct 24, 2024
This worked for me.
AlexanderPolenov commentedon Dec 12, 2024
To make it work with MySQL & NextJS 15+ add this to next.config.mjs:
Also, when connect to DB use
127.0.0.1and not thelocalhost. Because this will be the second problem that you will face.yueisme commentedon Apr 6, 2025
this work for me: