-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
If I try to connect to a database Webpack throws this:
ERROR in ./~/mysql/lib/Connection.js
Module not found: Error: Cannot resolve module 'net' in C:\Wamp64\www\react\node_modules\mysql\lib
@ ./~/mysql/lib/Connection.js 2:23-37
ERROR in ./~/mysql/lib/Connection.js
Module not found: Error: Cannot resolve module 'tls' in C:\Wamp64\www\react\node_modules\mysql\lib
@ ./~/mysql/lib/Connection.js 3:23-37
ERROR in ./~/mysql/lib/protocol/sequences/Query.js
Module not found: Error: Cannot resolve module 'fs' in C:\Wamp64\www\react\node_modules\mysql\lib\protocol\sequences
@ ./~/mysql/lib/protocol/sequences/Query.js 6:19-32
I don't know if this is an error my mysql or if it is caused by webpack or nodejs (I cannot load the module even if I write var x = require("fs");
outside the mysql function (anywhere in my code))
My webpack.config.js:
module.exports = {
entry: "./src/App.js",
output: {
path: __dirname,
filename: "app.js"
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel",
query: {
presets: ["es2015", "react"]
}
}]
}
};
And my package.json:
{
"name": "react",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.7.*",
"babel-loader": "^6.2.*",
"babel-preset-es2015": "^6.18.*",
"babel-preset-react": "^6.16.*",
"webpack": "^1.13.*",
"webpack-dev-server": "^1.16.*"
},
"dependencies": {
"react": "^15.3.*",
"react-dom": "^15.3.*",
"mysql": "^2.12.*",
"express": "^4.14.*"
}
}
My Code (just the mysql function):
var mysql = require("mysql");
var user = this.refs.username.value;
var password = this.refs.password.value;
var sqlCommand = "SELECT * FROM users WHERE user = '".concat(username, "' AND pass = '", password, "'");
//console.log(user + " - " + password);
var connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "lg"
});
connection.connect();
connection.query(sqlCommand, function(err, rows, fields){
if(!err){
console.log(rows);
console.log(fields);
}else{
console.log("Error while querying: ".concat(err));
}
});
connection.end();
codyromano, gyurobenjamin, AlexandreRozier, ktbee, piksu and 5 more
Metadata
Metadata
Assignees
Labels
No labels