[英]Execute nodejs on azure vm (windows server 2012)?
我已经在Visual Studio中与Node.js建立了聊天功能,并且在我的本地主机上运行良好,但是在Azure上我的网站运行良好,所以我创建了虚拟机(Windows Server 2012)。(注意:这不是经典的虚拟机)并安装了必要的软件NodeJS 。并将我的nodejsapp文件夹复制到虚拟机中。
此处的代码段(server.js)...
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io').listen(http);
var sql = require('mssql');
var config = {
user: 'xxxxx',
password: 'xxxxxxxxxxx',
server: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
database: 'xxxxx',
options: {
encrypt: true // Use this if you're on Windows Azure
}
}
console.log(config);
io.sockets.on('connection', function(socket){
socket.on('join room', function (data) {console.log('joined-->'+data.email);
socket.join(data.email);
});
socket.on('leave room', function (data) {console.log('Leaved-->'+data.email);
socket.leave(data.email);
});
socket.on('message', function (data) {
console.log('sent==>'+data.id+" , "+data.to+' , '+data.from+' , '+data.msg );
io.sockets.in(data.to).emit('chat message', {id: data.id, to:data.to,from: data.from, msg: data.msg });
});
});
http.listen(5556, function(){
console.log('listening on *:5556');
});
之后,使用命令提示符尝试运行server.js,但不运行node。
它在本地计算机上工作,但在vm中不工作。
谁能指出我正确的方向?
似乎另一个程序在环境路径中具有node.exe。 在您的情况下,可能是Microsoft HPC Pack。 键入echo%PATH%并查看(C:\\ Program Files \\ Microsoft HPC Pack 2008 R2 \\ Bin)是否位于node.js文件夹(C:\\ Program Files \\ nodejs)之前。 如果是这样,请更改路径,使node.js路径位于HPC路径之前。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.