在 ubuntu 14.04 VPS 上执行.js文件错误
Executing .js file on ubuntu 14.04 VPS error
当我尝试在 ubuntu 上运行我的 sell.js javascript 时,您好,我收到此错误:
节点卖出.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 安装 --保存加密,但它不起作用,我总是收到此错误.. 如果有人知道如何解决这个问题,请告诉我。
根据反馈和测试,问题在于目前 Ubuntu 14.04 仓库有 Node 0.10 分支。在此分支中,crypto.publicEncrypt API 函数不存在。您必须安装 4.x 或 5.x 版节点.js才能使用这些功能。
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
对于节点.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
相关文章:
- Meteor:插入集合后如何执行JS
- 如何在Odoo 9中执行JS文件中的函数
- 匿名自执行js函数内部的全局变量在外部仍然可用
- NumericTextBox-当用户键入数字时执行JS计算.能做到吗
- 引导:响应式设计-当窗口大小从980px调整到979px时执行JS
- 对页面上的所有ID执行JS功能
- 从浏览器访问页面时执行js函数's后退按钮
- 源代码未完全执行.(JS)
- 在执行JS脚本后监视对DOM的更改
- 在表单同步提交后执行 js 吗?
- 在 ubuntu 14.04 VPS 上执行.js文件错误
- 从PHP插入时在MongoDB上执行JS
- 在将ajax内容应用到元素后执行js函数
- Windows Phone浏览器控件执行JS函数来替换src属性
- 到达新页面后执行js
- 用C#在Win 8.1 Chakra中执行JS的一个失败的最小例子
- 在sharepoint显示模板中执行JS
- 在Bootstrap popover内部执行JS
- 从引导程序popover内容内部执行js
- 顺序执行js