你好,我在安装npm时遇到问题:我尝试删除并重新安装,但没有成功,甚至删除了所有文件夹。
> lucas@lucas:~$ npm install
> npm ERR! install Couldn't read dependencies
> npm ERR! Linux 4.2.0-35-generic
> npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
> npm ERR! node v4.4.2
> npm ERR! npm v2.15.0
> npm ERR! file /home/lucas/package.json
> npm ERR! code EJSONPARSE
> npm ERR! Failed to parse json
> npm ERR! Unexpected token ':' at 1:17
> npm ERR! "dependencies": {
> npm ERR! ^
> npm ERR! File: /home/lucas/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! /home/lucas/npm-debug.log
NPM告诉你发生了什么:
> npm ERR! File: /home/lucas/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
请确保您的JSON文件有效。您可以在JSONLint上查看。以下是依赖项部分的外观。请注意周围的对象括号。
{ "dependencies" :
{ "foo" : "1.0.0 - 2.9999.9999"
, "bar" : ">=1.0.2 <2.1.2"
, "baz" : ">1.0.2 <=2.3.4"
, "boo" : "2.0.1"
, "qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
, "asd" : "http://asdf.com/asdf.tar.gz"
, "til" : "~1.2"
, "elf" : "~1.2.3"
, "two" : "2.x"
, "thr" : "3.3.x"
, "lat" : "latest"
, "dyl" : "file:../dyl"
}
}
请参阅这篇关于NPM文档中"依赖项"部分的文章,并确保您的package.json
部分看起来相似,尤其是"依赖性"之前的任何字符。