HI all
I ma just starting with this and what i am trying to do is connect to mysql database after i get a webhook from manychat , at the moment i am getting a error
Error: Cannot find module 'mysql'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/app.js:21:15)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
That error message probably means that you have a problem with your pnpm module installation; probably the mysql package isn’t installed properly. There can be a number of reasons for this. It will be most helpful to be able to look at your project to offer specific recommendations, but you could start with providing the contents of your package.json file instead.
You could also run enable-pnpm in your project’s console and watch the logs while your project reinstalls its modules. There may be a more useful error message in the installation logs, but those will only show when you run that command, so you’d have to watch carefully.
// server.js
// where your node app starts
// init project
var express = require('express');
var app = express();
//const requestPromise = require('request-promise');
// we've started you off with Express,
// but feel free to use whatever libs or frameworks you'd like through `package.json`.
app.use(express.static('public'));
//=======================================================================================
// Get the Client data from database
//=======================================================================================
//app.get("/Getcompany", function (request, response) {
const mysql = require('mysql');
const connection = mysql.createConnection({
host: '****',
user: '***',
password: '*******',
database: '***'
});
connection.connect((err) => {
if (err) throw err;
console.log('Connected!');
});
//});
Ok, you’re not asking Glitch to install the MySQL package which is why Node can’t find it. You want something like this in your package.json:
“request”: “^2.72.0”,
“mysql”: “^2.16.0”
Basically, you need to add that 2nd line. Then your project should install the MySQL package and get you past this error.
Also, I’ve removed your database details from your post, but it’s very possible that they’ve been exposed to anyone who’s viewed the topic. You should at least change your database password as soon as you can.
connection.connect((err) => {
if (err) throw err;
console.log(‘Connected!’);
});
//});
myjs is not good i had someone do this for me and send it (i paid for it) and didnt work so i am trying to get it to work myself sorry for been a pain
at Protocol.handshake (/rbd/pnpm-volume/3160be57-a3d3-4afa-a888-c9055686dbc7/node_modules/.registry.npmjs.org/mysql/2.16.0/node_modules/mysql/lib/protocol/Protocol.js:51:23)
4:14 PM
at Connection.connect (/rbd/pnpm-volume/3160be57-a3d3-4afa-a888-c9055686dbc7/node_modules/.registry.npmjs.org/mysql/2.16.0/node_modules/mysql/lib/Connection.js:118:18)
4:14 PM
Jump to
at Object.<anonymous> (/app/app.js:28:12)
4:14 PM
at Module._compile (module.js:653:30)
4:14 PM
at Object.Module._extensions…js (module.js:664:10)
It looks to me (from testing the IP address I removed from your post and the typical MySQL port) that that IP address (defined in the host property) doesn’t have MySQL running on it, or it’s running on a non-standard port. Where did you come by that connection information, and can you confirm you have the right IP Address / host information?
ok got it working i know it is off topic but when you look at my code and i take the comment from the get.app i get a error any suggestions . i think you know what i am trying to do