我尝试在我的项目目录中安装一个包(〜/ WebstormProjects / untitled3)并得到以下消息
注意它在我的用户目录中找到一个package.json(Users / Nick / package.json)而不是我的项目目录
这是我的npm-debug.log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.3.0/bin/node',
1 verbose cli '/Users/Nick/.npm-packages/bin/npm',
1 verbose cli 'install',
1 verbose cli 'express',
1 verbose cli '--save-dev' ]
2 info using npm@3.9.5
3 info using node@v6.3.0
4 verbose config Skipping project config: /Users/Nick/.npmrc. (matches userconfig)
5 silly loadCurrentTree Starting
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 silly rollbackFailedOptional Starting
9 silly rollbackFailedOptional Finishing
10 silly runTopLevelLifecycles Starting
11 silly runTopLevelLifecycles Finishing
12 silly install printInstalled
13 verbose stack Error: Failed to parse json
13 verbose stack No data, empty input at 1:1
13 verbose stack
13 verbose stack ^
13 verbose stack at parseError (/Users/Nick/.npm-packages/lib/node_modules/npm/node_modules/read-package-json/read-json.js:390:11)
13 verbose stack at parseJson (/Users/Nick/.npm-packages/lib/node_modules/npm/node_modules/read-package-json/read-json.js:79:23)
13 verbose stack at /Users/Nick/.npm-packages/lib/node_modules/npm/node_modules/read-package-json/read-json.js:48:5
13 verbose stack at /Users/Nick/.npm-packages/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
13 verbose stack at tryToString (fs.js:455:3)
13 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)
14 verbose cwd /Users/Nick/WebstormProjects/untitled3
15 error Darwin 15.3.0
16 error argv "/usr/local/Cellar/node/6.3.0/bin/node" "/Users/Nick/.npm-packages/bin/npm" "install" "express" "--save-dev"
17 error node v6.3.0
18 error npm v3.9.5
19 error file /Users/Nick/package.json
20 error code EJSONPARSE
21 error Failed to parse json
21 error No data, empty input at 1:1
21 error
21 error ^
22 error File: /Users/Nick/package.json
23 error Failed to parse package.json data.
23 error package.json must be actual JSON, not just JavaScript.
23 error
23 error This is not a bug in npm.
23 error Tell the package author to fix their package.json file. JSON.parse
24 verbose exit [ 1, true ]
- 好的,我已经删除了/Users/Nick/package.json,但现在包安装在/ Users / Nick / node_modules
答案 0 :(得分:1)
您的目录中已有package.json
,但配置不正确。尝试检查,或在此处发布,我们将提供帮助。
似乎/Users/Nick/package.json
是违规文件 - 尝试将其删除,除非有理由将其存在。
供参考:
package.json
时 - 得到了同样的错误。 :)修改:根据您的修改,请尝试以下操作:
答案 1 :(得分:0)
尝试npm install express --save-dev