[英]Err: install Couldn't read dependencies - While executing command npm install
我正在nodejs工作场所的https://ide.c9.io中工作。 在创建工作场所时,c9.io提供了一个用nodejs开发的示例聊天应用程序
为了进一步扩展功能,我想安装mysql模块。 所以我修改了如下的package.json文件,并添加了“ node-mysql”。
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server with `async` for control flow.",
"main": "server.js",
"repository": "",
"author": "Mostafa Eweda <mo.eweda@gmail.com>",
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"socket.io": "~0.9.14"
}
}
{
"name": "node-mysql",
"version": "0.0.1",
"dependencies": {
"express": "^4.10.6",
"mysql": "^2.5.4"
}
}
但这给了我如下错误
npm ERR! install Couldn't read dependencies
npm ERR! Failed to parse json
npm ERR! Unexpected token {
npm ERR! File: /home/ubuntu/workspace/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! System Linux 3.14.13-c9
npm ERR! command "/home/ubuntu/.nvm/v0.10.35/bin/node" "/home/ubuntu/.nvm/v0.10.35/bin/npm" "install"
npm ERR! cwd /home/ubuntu/workspace
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! file /home/ubuntu/workspace/package.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/ubuntu/workspace/npm-debug.log
npm ERR! not ok code 0
让我知道我在做什么。 我用于package.json的JSON格式是错误的。
当我分别使用“聊天示例”或“聊天示例”模块时-它们安装正确。
日志明确提到您的package.json文件无效。 为了添加node-mysql,您所要做的就是将其添加到依赖关系部分,如下所示(编写0.4.2是node-mysql的最新版本,如果需要其他版本,只需指定它即可):
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server with `async` for control flow.",
"main": "server.js",
"repository": "",
"author": "Mostafa Eweda <mo.eweda@gmail.com>",
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"socket.io": "~0.9.14",
"node-mysql": "^0.4.2"
}
}
清楚地说:
npm ERR! Failed to parse json
表示它不是有效的json。
使其成为有效的JSON。
它是有效的json:
{
"name": "chat-example",
"version": "0.0.0",
"description": "A chat example to showcase how to use `socket.io` with a static `express` server with `async` for control flow.",
"main": "server.js",
"author": "Mostafa Eweda <mo.eweda@gmail.com>",
"dependencies": {
"async": "~0.2.8",
"express": "~3.2.4",
"socket.io": "~0.9.14",
"node-mysql": "^0.4.2"
}
}
我刚刚修改了@Johnny Tordgeman的帖子
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.