当我尝试使用npm安装express时,我总是会收到以下错误:
Failed to parse json
No data, empty input at 1:1
File: /root/.npm/inherits/2.0.1/package/package.json
Failed to parse package.json data.
package.json must be actual JSON, not just JavaScript.
This is not a bug in npm.
Tell the package author to fix their package.json file. JSON.parse
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
sudo npm install -g express
Run Code Online (Sandbox Code Playgroud)
操作系统是Ubuntu 12.04(精确)armhf
我试图用https运行我的节点服务器.我正在使用express和socket.io.
这是我的https代码:
var httpsPort = 443;
var privateKey = fs.readFileSync(mykeypath');
var certificate = fs.readFileSync(mycertificatepath');
var credentials = {key: privateKey, cert: certificate};
var https = require('https').Server(credentials,app);
var io = require('socket.io')(https);
https.listen(httpsPort, function(){
logger.info('listening on *:' + httpsPort);
});
app.get('/initGame', function (req,res){
var slots = require('./slots.json', 'utf8');
var userObject = {
address : req.connection.remoteAddress,
userAgent : req.headers['user-agent']
};
db.getPlayedGames(userObject,function(playedGames){
logger.debug(playedGames);
if(typeof playedGames == 'undefined' ){
playedGames=0;
}else{
playedGames = playedGames.games_played;
}
var spinsLeft = 10-playedGames;
res.json({
spinsLeft: spinsLeft,
slots: slots
});
}); …Run Code Online (Sandbox Code Playgroud)