Remote shared server mysql2 error

well the mysql2 module is somehow still missing. So either install it somehow or switch back your database connection to use the old mysql package.

Scott, can you go into cPanel and into “Setup Node.js App”

Click on edit your application

click here to view package.json

You should see mysql2 listed

Click Run NPM install

This should install the NPM package. Occasionally NPM install fails, just rerun it.

This worked for me

Thats what strikes me as so funny because that’s step by step what I did. :frowning:

I removed the nodejs app from the CPanel, deleted the nodevenv created by OrangeHost and deleted the entire nodejsapp and deleted the .npm from the root.

I created a new folder, named app. Published from Wappler. Created a new nodejs app in the CPanel.

Checked the package to make sure that mysql2 was there. It had a higher version (looks like one was just released). Changed the version number to match yours. Saved it. Installed NPM. No errors. Started the nodejs app.

Screenshot 2024-04-21 at 6.24.30 AM

Original error persists. Only difference is it is showing “app” as the directory instead of “nodejsapp” due to my changing the directory.

{
"status": "500",
"message": "Knex: run\n$ npm install mysql2 --save\nopen EEXIST",
"stack": "Error: Knex: run\n$ npm install mysql2 --save\nopen EEXIST\n    at Client_MySQL2.initializeDriver (/home/usofapag/nodevenv/app/20/lib/node_modules/knex/lib/dialects/mysql2/index.js:33:13)\n    at new Client (/home/usofapag/nodevenv/app/20/lib/node_modules/knex/lib/client.js:83:12)\n    at new Client_MySQL2 (/home/usofapag/nodevenv/app/20/lib/node_modules/knex/lib/dialects/mysql2/index.js:9:1)\n    at knex (/home/usofapag/nodevenv/app/20/lib/node_modules/knex/lib/knex-builder/Knex.js:16:28)\n    at App.setDbConnection (/home/usofapag/app/lib/core/app.js:407:27)\n    at App.getDbConnection (/home/usofapag/app/lib/core/app.js:426:25)\n    at App.single (/home/usofapag/app/lib/modules/dbconnector.js:262:25)\n    at App._exec (/home/usofapag/app/lib/core/app.js:611:57)\n    at App._exec (/home/usofapag/app/lib/core/app.js:578:28)\n    at async App.exec (/home/usofapag/app/lib/core/app.js:547:9)"
}

got any backups to roll back to? Think it keeps 3 automatically

The only thing I can see that is didn’t do was delete .npm folder.
Has it been correctly recreated?

Yes, deleted an hour ago. I also noticed that our nodejs versions do not match, but I would not think that would be an issue.

Wappler uses v18 by default but encompasses v16 -20

Has .npm folder been fully and correctly recreated?

For info, i have tried everything to reproduce your error but can’t, everything works as it should.
Even reverted site back to a pre 6.5.0 backup and re upgraded site but everything worked as it should

I appreciate the time you spent on this @Hyperbytes trying to help me out. I have to chalk it up to there is something wrong with the shared server that I am on. That is the only thing that makes any sense.

Check for backups on the control panel, I think they are automatic and roll back. Worked for me when I issued an invalid config command and screwed up the server.

Trying that and we’ll see. :slight_smile:

Hello Scott.
Did you resolve this issue.
I am getting frustrated on this and i need help.

Thanks

No, I switched to AWS and docker.

BACKUP EVERYTHING FIRST!

You can try opening your database connection and changing the driver from MySQL/MariaDB (depreciated) to MySQL/MariaDB. This should add the MySQL2 package to your package-lock.json file.

To confirm this when you make the change have the Output panel open and you will see if it is added.

image

Then it is worth following up by clicking on Install Node Packages / Update Node Packages / Clean Node Packages (next to the Output button).

Then deploy to your host and restart the Container.

Thanks, I am trying that NOW…will revert.

BACKUP BACKUP BACKUP!

Failing the above you can also try removing your current database connection (be sure to remember the name as it is used in your Server Actions), and re-creating it as a new connection. This will do the same and add the MySQL2 package to your package-lock.json.

IMPORTANT to have the same name (EXACTLY) for the new connection as the old connection (sorry for the repeat).

:wink:

Followed the steps above…still get error…

“status”: “500”,
“message”: “Knex: run\n$ npm install mysql2 --save\nopen EEXIST”,
“stack”: "Error: Knex: run\n$ npm install mysql2 --save\nopen EEXIST\n at Client_MySQL2.initializeDriver

Really strange, I had no problems at all after running NPM from the orangehost control panel

Is NPM installed on the host?

1 Like

Yes, npm is installed but needs to be run with full path (instructions in my tutorial) but the easiest way is to ensure mysql2 is in the dependencies list produced by wapper and running a full npm install from the orangehost control panel which will add any missing packages.