Json 为什么npm安装don';我不能在ubuntu 18.04中工作

Json 为什么npm安装don';我不能在ubuntu 18.04中工作,json,npm,ubuntu-18.04,Json,Npm,Ubuntu 18.04,我正在尝试使用以下命令安装hooper fpr和vue.js示例: $ npm install hooper 告诉我下一个错误 npm ERR! file /home/juanlh/package.json npm ERR! code EJSONPARSE npm ERR! JSON.parse Failed to parse json npm ERR! JSON.parse Unexpected end of JSON input while parsing near '' npm ERR!

我正在尝试使用以下命令安装hooper fpr和vue.js示例:

$ npm install hooper
告诉我下一个错误

npm ERR! file /home/juanlh/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/juanlh/.npm/_logs/2019-03-16T14_39_47_947Z-debug.log
日志:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'install', 'hooper' ]
2 info using npm@6.9.0
3 info using node@v8.10.0
4 verbose config Skipping project config: /home/juanlh/.npmrc. (matches userconfig)
5 verbose npm-session e3d2c58aee19e2f6
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 timing stage:rollbackFailedOptional Completed in 6ms
9 timing stage:runTopLevelLifecycles Completed in 124ms
10 verbose stack Error: Failed to parse json
10 verbose stack Unexpected end of JSON input while parsing near ''
10 verbose stack     at parseError (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:452:11)
10 verbose stack     at parseJson (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:104:26)
10 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:51:5
10 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:16
10 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
11 verbose cwd /home/juanlh
12 verbose Linux 4.18.0-16-generic
13 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "install" "hooper"
14 verbose node v8.10.0
15 verbose npm  v6.9.0
16 error file /home/juanlh/package.json
17 error code EJSONPARSE
18 error JSON.parse Failed to parse json
18 error JSON.parse Unexpected end of JSON input while parsing near ''
19 error JSON.parse Failed to parse package.json data.
19 error JSON.parse package.json must be actual JSON, not just JavaScript.
20 verbose exit [ 1, true ]

package.json不是创建的,我自己创建的,它是空的。

空的
包。json
不是有效的json(因此不是有效的package.json)

比如说

$ echo -n > package.json

$ npm install left-pad
npm ERR! file /tmp/x/x/x/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/asottile/.npm/_logs/2019-03-16T16_28_09_404Z-debug.log
执行安装的最小
package.json
{}
(这是有效的json:空映射)

您也可以完全删除
package.json

$ rm -rf package.json node_modules
$ npm install left-pad
npm WARN saveError ENOENT: no such file or directory, open '/tmp/x/x/x/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/tmp/x/x/x/package.json'
npm WARN x No description
npm WARN x No repository field.
npm WARN x No README data
npm WARN x No license field.

+ left-pad@1.3.0
$ rm -rf package.json node_modules
$ npm install left-pad
npm WARN saveError ENOENT: no such file or directory, open '/tmp/x/x/x/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/tmp/x/x/x/package.json'
npm WARN x No description
npm WARN x No repository field.
npm WARN x No README data
npm WARN x No license field.

+ left-pad@1.3.0