[英]ruby on rails application with ember.js on ubuntu 14.04
[英]Executing .js file on ubuntu 14.04 VPS error
您好,當我嘗試在ubuntu上運行我的sell.js javascript時,出現以下錯誤:
節點sell.js
socket timed out
socket closed
connecting to 72.165.61.175:27018
connected
encrypt request
/var/www/bot/node_modules/steam/lib/steam_client.js:150
var cryptedSessKey = require('crypto').publicEncrypt(fs.readFileSync(__dirna
^
TypeError: Object #<Object> has no method 'publicEncrypt'
at SteamClient.handlers.(anonymous function) (/var/www/bot/node_modules/steam/lib/steam_client.js:150:42)
at SteamClient._netMsgReceived (/var/www/bot/node_modules/steam/lib/steam_client.js:106:26)
at Connection.emit (events.js:95:17)
at Connection._readPacket (/var/www/bot/node_modules/steam/lib/connection.js:50:8)
at Connection.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:427:10)
at emitReadable (_stream_readable.js:423:5)
at readableAddChunk (_stream_readable.js:166:9)
at Connection.Readable.push (_stream_readable.js:128:10)
at TCP.onread (net.js:529:21)
/var/www/bot/node_modules/steam/lib/steam_client.js中的代碼:
handlers[EMsg.ChannelEncryptRequest] = function(data) {
this._connection.setTimeout(0);
this.emit('debug', 'encrypt request');
this._tempSessionKey = require('crypto').randomBytes(32);
var cryptedSessKey = require('crypto').publicEncrypt(fs.readFileSync(__dirname + '/public.pub'), this._tempSessionKey);
var keyCrc = require('buffer-crc32').signed(cryptedSessKey);
var encResp = new schema.MsgChannelEncryptResponse().encode();
var body = new ByteBuffer(encResp.limit + 128 + 4 + 4, ByteBuffer.LITTLE_ENDIAN);
body.append(encResp);
body.append(cryptedSessKey);
body.writeInt32(keyCrc);
body.writeUint32(0);
this._send(EMsg.ChannelEncryptResponse, body.flip());
};
我做了npm install --save crypto,但是它不起作用,我總是收到這個錯誤..如果有人知道如何解決這個問題,請告訴我。
根據反饋和測試,當前的問題是Ubuntu 14.04存儲庫具有Node 0.10分支。 在此分支中,crypto.publicEncrypt API函數不存在。 您必須安裝4.x或5.x版本的node.js才能使用這些功能。
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
對於Node.js v4:
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
另外,對於Node.js v5:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
可選 :安裝構建工具
要從npm編譯並安裝本機插件,您可能還需要安裝構建工具:
sudo apt-get install -y build-essential
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.