我尝试使用以下命令在vue.js示例中安装hooper fpr:
conversion_method
告诉我下一个错误
$ 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
package.json没有创建,我自己创建,并且为空。
答案 0 :(得分:3)
空的package.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:一个空映射)
$ echo '{}' > package.json
$ npm install left-pad
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN x No description
npm WARN x No repository field.
npm WARN x No license field.
+ left-pad@1.3.0
added 1 package from 1 contributor and audited 1 package in 0.677s
found 0 vulnerabilities
您也可以完全删除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