2015-08-29 148 views
2

我剛剛添加了一個mysql連接,但腳本一直失敗。錯誤在下面,相關的js低於此值。NodeJS MySQL連接失敗

TypeError: 'undefined' is not a function (evaluating 'loadClass.bind(null, 'Types')') 

    app/node_modules/mysql/index.js:92 
    app/node_modules/mysql/index.js:138 
Error: Cannot find module 'crypto' 

    phantomjs://bootstrap.js:289 
    phantomjs://bootstrap.js:254 in require 
    app/node_modules/mysql/lib/Connection.js:1 
    app/node_modules/mysql/lib/Connection.js:420 
TypeError: '[object Object]' is not a constructor (evaluating 'new Connection({config: new ConnectionConfig(config)})') 

    app/node_modules/mysql/index.js:12 in createConnection 

app.js

var Q = require("q"); 
var page = require('webpage').create(); 
//var crypto = require('./node_modules/crypto/sha1.js'); 
var mysql = require('mysql'); 

var connection = mysql.createConnection({ 
    host  : 'localhost', 
    user  : 'shaun', 
    password : 'somepassword', 
    database : 'db' 
}); 

connection.connect(); 
+0

NodeJS默認爲SSL嗎? – hd1

+0

我也看看這些: app/node_modules/mysql/index.js:12 app/node_modules/mysql/index.js:92 app/node_modules/mysql/index.js:138 app/node_modules/mysql /lib/Connection.js:1 app/node_modules/mysql/lib/Connection.js:420 – isaac9A

+0

是的,我想我必須在SQL模塊上打開一個問題。 https://github.com/felixge/node-mysql – Shaun

回答

0

Error: Cannot find module 'crypto'

你試過npm install crypto?你的應用有一個package.json嗎?如果是的話,你做了npm install

+0

是的,我已經安裝了加密。此錯誤來自節點模塊(來自npm),https://github.com/felixge/node-mysql – Shaun