Node.js에 'db-mysql'이라는 this 데이터베이스 플러그인을 설치했는데 오류가 발생하지 않고 사이트에 언급 된 모든 단계를 거쳤습니다. 플러그인이 설치되었는지 확인하십시오. 그러나 아파치 서버에서 .js 파일 (아래 명시)을 실행할 때이 오류가 발생합니다.Node.js 플러그인을 Ubuntu 12.04에 설치할 수 없습니다.
Error: Cannot find module 'db-mysql'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/var/www/server.js:4:13)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
다음은 실행중인 샘플 코드입니다.
var http = require("http");
var mysql = require("db-mysql");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
//Database Connectivity//
new mysql.Database({
hostname: 'localhost',
user: 'root',
password: '',
database: 'test'
}).on('error', function(error) {
console.log('ERROR: ' + error);
}).on('ready', function(server) {
console.log('Connected to ' + server.hostname + ' (' + server.version + ')');
}).connect();
///////////////////////
response.end();
}).listen(8889);
설치 중에 아무 것도 없습니까?