npm安装错误 – 无效的package.json

我正在使用这个教程来理解在Node.js中实现oauth2。

这是我的package.json:

{ "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": "coffee -w server.coffee" }, "dependencies": { "express": "3.3.4", "jade": "*", "coffee-script": "latest", "passport-http": "latest", "passport-http-bearer": "latest", "passport-oauth2-client-password": "latest", "oauth2orize": "latest", "debug" "~0.7.2" } } 

我收到错误:

 npm ERR! install Couldn't read dependencies npm ERR! Failed to parse json npm ERR! Unexpected string npm ERR! File: /Users/jashua/Desktop/auth/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 Darwin 12.3.0 npm ERR! command "node" "/usr/local/bin/npm" "install" npm ERR! cwd /Users/jashua/Desktop/auth npm ERR! node -v v0.10.15 npm ERR! npm -v 1.3.5 npm ERR! file /Users/jashua/Desktop/auth/package.json npm ERR! code EJSONPARSE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/me/Desktop/auth/npm-debug.log npm ERR! not ok code 0 

任何想法有什么不对我的package.json?

这个错误意味着它的状态,你的package.json的JSON是无效的,不能正确parsing。 将"debug" "~0.7.2"更改为"debug": "~0.7.2"

由于npm错误,我到达了这个页面,但是原因不同。 查看日志文件后,我意识到npm不喜欢我对文件顶部的评论。

 // package.json { ... } 

删除所有评论后,npm精美地浏览了所有内容。 我的评论是没有必要的,所以我很好,因为它是。 但是,如果您需要在您的XML中的注释,请参阅如何添加注释到npm install的package.json?

我遇到了同样的问题,由我对我的package.json文件所做的更改。 我刚刚还原到我的备份版本的package.json文件。 如果有其他人需要,我附上:

 {"name": "OpenShift-Sample-App", "version": "1.0.0", "description": "OpenShift Sample Application", "keywords": [ "OpenShift", "Node.js", "application", "openshift" ], "author": { "name": "OpenShift", "email": "ramr@example.org", "url": "http://www.openshift.com/" }, "homepage": "http://www.openshift.com/", "repository": { "type": "git", "url": "https://github.com/openshift/origin-server" }, "engines": { "node": ">= 0.6.0", "npm": ">= 1.0.0" }, "dependencies": { "express": "~3.4.4" }, "devDependencies": {}, "bundleDependencies": [], "private": true, "main": "server.js" } 

有时你的package.json可能会有一些奇怪的Unicode字符。 例如,你可能有(unicode non-breaking space)而不是某处的空间。 在编辑器中看起来是一样的,所以要小心。

(从博客复制一小部分configuration后,我只是有这样的问题。)

使用这个命令来修复package.json相关的问题。

npmcaching清理

我的项目在D:\ wwwroot \ Projetos 2017 \ Android \ PluginTest \ PluginTest \ plugins \ cordova-plugin-iservice

问题是在2017年Projetos(这里)之间的空间

我删除了空间:D:\ wwwroot \ Projetos2017 \ Android \ PluginTest \ PluginTest \ plugins \ cordova-plugin-iservice

和工作正常