拥有以下代码 -
var http = require('http');
var mysql = require('mysql');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
当我试图跑步时,我收到以下错误 -
错误:找不到模块'mysql'
虽然我安装了mysql模块。 这有些奇怪,我用npm install mysql安装了它但是......
npm ls
返回
└──(空)
正在运行
“npm prefix”
返回/ home / user,而
npm config获取前缀
返回
/home/user/.node
使得它更奇怪的事实是我在〜/ .node / lib / node_modules / mysql和〜/ .npm / mysql / 2.3.2 / package中都有mysql包(另外,.npm包含更多包)
我很感激任何帮助