qq_30511823 2019-07-10 11:09 采纳率: 50%
浏览 358
已结题

node.js 访问mysql 缺少 net, fs, tls模块问题

图片说明
图片说明图片说明

node.js 新人,连接mysql 提示缺少 net, fs, tls这三个模块,install 后也不行,

 Uncaught (in promise) Error: Cannot find module "fs"
    at webpackMissingModule (eval at <anonymous> (index@dev.js:6669), <anonymous>:6:84)
at Object.eval (eval at <anonymous> (index@dev.js:6669), <anonymous>:6:163)
at eval (eval at <anonymous> (index@dev.js:6669), <anonymous>:220:30)
at Object.<anonymous> (index@dev.js:6669)
at __webpack_require__ (manifest@dev.js:586)
at fn (manifest@dev.js:110)
at eval (eval at <anonymous> (index@dev.js:6459), <anonymous>:4:17)
at Object.<anonymous> (index@dev.js:6459)
at __webpack_require__ (manifest@dev.js:586)
at fn (manifest@dev.js:110)![图片说明](https://img-ask.csdn.net/upload/201907/10/1562728093_443188.png)![图片说明](https://img-ask.csdn.net/upload/201907/10/1562728145_157571.png)

代码:
execuSql() {
console.log('666666666');
var mysql = require('mysql');
var connection = mysql.createConnection({host:'172.22.33.22',user:'root',password:'root',port:'3306',database:'test'});
connection.connect();

var  sql = 'SELECT * FROM scipt where id = 1208';
//查
connection.query(sql,function (err, result) {
        if(err){
          console.log('[SELECT ERROR] - ',err.message);
          return;
        }

      console.log('--------------------------SELECT----------------------------');
      console.log(result);
      console.log('------------------------------------------------------------\n\n');  
});
connection.end();

}

  • 写回答

4条回答 默认 最新

  • DarkSupe 2019-07-10 11:12
    关注

    你看你项目的目录有没有node_modules这个文件夹,这里是放你安装的模块的,找不到模块要么就是你没安装,要么就是你没引入。仔细检查一下吧

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配