js和MySQL导致node / no"/>
React.js和MySQL导致node / no
[尝试为我的React应用程序构建后端数据库,并在尝试导入相关的MySQL库时,它将引发错误。从终端运行它没有问题,但是当我将其放入时,会收到以下错误:
./ src / data / node_modules / mysql / node_modules / safe-buffer / index.js第1:1行:未找到规则'node / no-deprecated-api'的定义node / no-deprecated-api
搜索时无法找到任何解决方案。
我的代码:
import {mysql} from 'mysql'; // Commenting out this one line stops the error
export default function tester() {
/*
const connection = mysql.createConnection({ // Commented out only when import is commented
host: 'localhost',
user: '<username>',
password: '<password>',
database: '<db name>'
});
connection.connect((err) => {
if (err) throw err;
console.log('Connected!');
});
*/
}
回答如下:对于以后阅读此书的任何人,解决方案是不直接连接到MySQL服务器,而是使用Express。
更多推荐
React.js和MySQL导致node / no
发布评论