Repository navigation
Closed
Description
What are you doing?
when I run 'node app.js' ,throw error 'new Error('Please install mysql2 package manually');'
but i'm installed mysql2.
my local client haven't this problem, just my ubuntu 14 server have it.
You must set the NODE_ENV environment variable
/home/www/test/tougao-server/node_modules/_sequelize@4.37.10@sequelize/lib/dialects/mysql/connection-manager.js:38
throw new Error('Please install mysql2 package manually');
^
Error: Please install mysql2 package manually
at new ConnectionManager (/home/www/test/tougao-server/node_modules/_sequelize@4.37.10@sequelize/lib/dialects/mysql/connection-manager.js:38:15)
at new MysqlDialect (/home/www/test/tougao-server/node_modules/_sequelize@4.37.10@sequelize/lib/dialects/mysql/index.js:14:30)
at new Sequelize (/home/www/test/tougao-server/node_modules/_sequelize@4.37.10@sequelize/lib/sequelize.js:239:20)
at Object.<anonymous> (/home/www/test/tougao-server/controllers/adController.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/www/test/tougao-server/router/ad.js:2:20)
at Module._compile (internal/modules/cjs/loader.js:678:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
at Module.load (internal/modules/cjs/loader.js:589:32)
at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
at Function.Module._load (internal/modules/cjs/loader.js:520:3)
at Module.require (internal/modules/cjs/loader.js:626:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /home/www/test/tougao-server/router/index.js:37:17
at Array.forEach (<anonymous>)
at Object.<anonymous> (/home/www/test/tougao-server/router/index.js:36:4)What do you expect to happen?
I wanted Foo!
What is actually happening?
But the output was bar!
Output, either JSON or SQL
Dialect: mysql
__Database version:_5.5.60
__Sequelize version: 4.37.10
__Tested with latest release: no
Note : Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template.
Reacted by Szabolcs Pasztor, siarhei-kudrautsau, Tejas Suthar, Hamed Soheili, Maxim, quyettv95 and Glauber Duarte Monteiro
Metadata
Metadata
Assignees
Labels
No labels
Activity
sushantdhiman commentedon May 29, 2018
Try removing your
node_modulesfolder then make sure both dependencies are installed locally. I am closing this issue as it seems to be a dependency issue, feel free to comment if it still doesn't works.cleiton-tavares commentedon Nov 26, 2018
I have the same problem, I have already tried to remove the
node_modulesfolder including globally install the mysql2 package but every time I run any command Sequelize CLI -" ERROR: Please install mysql2 package manually "I tried running CLI locally and globally as well.
My specs -> Sequelize CLI [Node: 10.12.0, CLI: 5.3.0, ORM: 4.38.1] and mysql2 1.6.4
pasha1307 commentedon Nov 26, 2018
..I am having the same issue with the error when try to run db:migrate
Sequelize CLI [Node: 11.2.0, CLI: 5.3.0, ORM: 4.41.2] Loaded configuration file "config/config.json".
Using environment "development".
ERROR: Please install mysql2 package manually.
Tried all the above and more - does not help. Is there any explanation why and how to fix it?
vmarushkoossystem commentedon Dec 13, 2018
Hi!
Try to understand real trouble. You need to find the following code and add
console.log()for displaying error's description:File:
node_modules/sequelize/lib/dialects/mysql/connection-manager.jsPlace:
After that you will be able to understand what is actually happened.
pasha1307 commentedon Dec 13, 2018
yes, it does make sense - yet, the error should not be specified then, if it may or may not be related to the sql package. Adds more confusion to the equasion. thank you.
catamphetamine commentedon Apr 24, 2019
If you're bundling with Webpack, my workaround for
v5is:The bug is in the code:
require(moduleName)won't work with Webpack.arielrahmane commentedon May 5, 2019
@catamphetamine I'm sorry if it is a rookie question, but in which file should I place that correction?
MaximusMcCann commentedon May 17, 2019
@arielrahmane wherever you import sequelize you can set the
dialectModulein the options. Example below.nahumzs commentedon Jul 1, 2019
The previous solution works correctly from MySql, but for Postgres is not working. I was able to go passed the
Please install pg package manuallyerror, and got stuck with an error complying aboutundefined of indexOf.Because I'm trying to use sequelize and serverless for a prototype, I changed my db selection to mysql, and simply move forward.
CovertIII commentedon Sep 19, 2019
I got this working with Postgres. As noted above use the
dialectModuleoption when initializing Sequelize v5 like so:To get past the
undefined of indexOferror add this to the webpack config:See these related issues:
brianc/node-postgres#1187
serverless-heaven/serverless-webpack#78
components added: form, grid, jumbotron(bugged), list, navbar(edited)…
benbowler commentedon Oct 31, 2019
I had this issue deploying to now.sh and was able to fix to add this dialectModule option directly in my Sequalize config:
valentinho27 commentedon Jul 22, 2020
in my case i use it !
add
const mysql2 = require('mysql2');
"development": {
"username": DB_USERNAME,
"password": DB_PASS,
"database": DB_NAME,
"host" : DB_HOST,
"dialect" : "mysql",
"dialectModule" : mysql2 // Needed to fix sequelize issues
}
knowself commentedon Sep 11, 2020
I was working through the Apollo GraphQL Tutorial ... https://www.apollographql.com/docs/tutorial/introduction/
... and ran into a brick wall until I did this ...
==============================
const {Sequelize} = require('sequelize');
const {sqlite} = require('sqlite3'); // Needed to fix sequelize issues with WebPack
module.exports.paginateResults = ({
.
.
.
module.exports.createStore = () => {
const db = new Sequelize({
dialect: 'sqlite',
dialectModule: sqlite, // Needed to fix sequelize issues with WebPack
storage: './store.sqlite'
});
.
.
.
Dead in the water until this post ... Thanks!!!
Try sequelize/sequelize#9489
papb commentedon Apr 4, 2021
Hello, I will concentrate all efforts involving Webpack problems in this new issue: #13169 - Please help me there if possible.
Sky-walker-only commentedon Apr 8, 2021
npm install mysql2 --global,npm install mysql2 --save; it's done;Mnabawy commentedon Jun 29, 2021
npm install --save mysql2
SumitJadiya commentedon Jul 7, 2021
repeating above queries fixed my problem
Fix: Deploy mysql webpack vercel
fix: mysql2 module not found(sequelize/sequelize#9489 (comment))
Kaleb11 commentedon Jul 12, 2023
wildy13 commentedon Sep 25, 2023
but I'm still error,
moxinnai commentedon May 18, 2025
use import * as mysql2 from 'mysql2' instead of import mysql2 from 'mysql2'
is worked for me