npm install error - invalid package.json
我正在使用本教程来了解在Node.js中实现oauth2。
这是我的package.json:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | { "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" } } |
我收到错误:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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有什么问题?
该错误意味着它所声明的内容,
我的项目在D: wwwroot Projetos 2017 Android PluginTest PluginTest plugins cordova-plugin-iservice
问题是Projetos(这里)2017之间的空间
我删除了空间:
d: wwwroot的 Projetos2017 Android的 PluginTest PluginTest 插件科尔多瓦 - 插件,iservice
工作正常
使用此命令修复package.json相关问题。
npm缓存清理
有时你的
(从博客复制一小段配置后,我遇到了这样的问题。)
我遇到了与我的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | {"name":"OpenShift-Sample-App", "version":"1.0.0", "description":"OpenShift Sample Application", "keywords": [ "OpenShift", "Node.js", "application", "openshift" ], "author": { "name":"OpenShift", "email":"[email protected]", "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" } |
由于相同的npm错误,我到达此页面,但原因不同。查看日志文件后,我意识到npm不喜欢我对文件顶行的评论。
1 2 3 | // package.json { ... } |
删除所有评论后,npm完美地浏览了所有内容。我的评论没有必要,所以我很好。但是如果您需要在xml中添加注释,请参阅如何为package.json添加注释以进行npm install?