Node.js openshift with socket.io,npm安装';不读依赖项
尝试在openshift上使用socket.io构建node.js服务器时,出现以下错误Node.js openshift with socket.io,npm安装';不读依赖项,node.js,socket.io,openshift,Node.js,Socket.io,Openshift,尝试在openshift上使用socket.io构建node.js服务器时,出现以下错误 npm ERR! install Couldn't read dependencies npm ERR! install Couldn't read dependencies npm ERR! Linux 3.10.0-753.el7xtsync.x86_64 npm ERR! argv "/opt/rh/rh-nodejs4/root/usr/bin/node" "/opt/rh/rh-nodejs4
npm ERR! install Couldn't read dependencies
npm ERR! install Couldn't read dependencies
npm ERR! Linux 3.10.0-753.el7xtsync.x86_64
npm ERR! argv "/opt/rh/rh-nodejs4/root/usr/bin/node" "/opt/rh/rh-nodejs4 /root/usr/bin/npm" "install"
npm ERR! node v4.6.2
npm ERR! npm v2.15.1
npm ERR! file /opt/app-root/src/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Cannot find module './lib/parse'
npm ERR! File: /opt/app-root/src/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! Please include the following file with any support request:
npm ERR! /opt/app-root/src/npm-debug.log
但是,代码在本地计算机上运行良好,没有任何错误
我使用以下package.json
{
"name": "socket_thing",
"version": "0.0.1",
"description": "To make a server plugin for superpowers",
"scripts": {
"start": "node server.js"
},
"main": "server.js",
"dependencies": {
"express": "^4.15.2",
"socket.io": "^2.0.4"
}
}
是否有任何原因可以解释为什么在openshift上处理依赖关系的方式会有所不同,因为这似乎就是问题所在?因此,使用最新版本的express
"express": "^4.16.2"
在package.json中解决了这个问题