React.js和MySQL导致node / no

编程入门 行业动态 更新时间:2024-10-08 02:28:49

React.<a href=https://www.elefans.com/category/jswz/34/1771451.html style=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

本文发布于:2024-05-07 12:59:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1756355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:js   React   node   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!