最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

React.js和MySQL导致nodeno

IT培训 admin 13浏览 0评论

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

[尝试为我的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。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论