electron执行npm报verbose stack SyntaxError: Unexpected end of JSON input while parsing near

根据官网的命令执行install:

npm install --save-dev electron

结果报错,查看日志如下:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'D:\\Program\\nodejs\\node.exe',
1 verbose cli   'D:\\Program\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   '--save-dev',
1 verbose cli   'electron'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v12.16.1
4 verbose npm-session 1d46db9f796af193
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/electron 935ms (from cache)
8 silly pacote tag manifest for electron@latest fetched in 954ms
9 timing stage:loadCurrentTree Completed in 976ms
10 silly install loadIdealTree
11 silly install cloneCurrentTreeToIdealTree
12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
13 silly install loadShrinkwrap
14 timing stage:loadIdealTree:loadShrinkwrap Completed in 1ms
15 silly install loadAllDepsIntoIdealTree
16 silly resolveWithNewModule electron@8.0.3 checking installable status
17 http fetch GET 304 https://registry.npmjs.org/@electron%2fget 268ms (from cache)
18 silly pacote range manifest for @electron/get@^1.0.1 fetched in 277ms
19 silly resolveWithNewModule @electron/get@1.8.0 checking installable status
20 http fetch GET 304 https://registry.npmjs.org/@types%2fnode 692ms (from cache)
21 silly fetchPackageMetaData error for @types/node@^12.0.12 Unexpected end of JSON input while parsing near '...dMUeoccc6a4wqX100lsCT'
22 http fetch GET 304 https://registry.npmjs.org/extract-zip 694ms (from cache)
23 silly pacote range manifest for extract-zip@^1.0.3 fetched in 695ms
24 silly resolveWithNewModule extract-zip@1.6.7 checking installable status
25 timing stage:rollbackFailedOptional Completed in 0ms
26 timing stage:runTopLevelLifecycles Completed in 1681ms
27 silly saveTree mianyang-demo@0.1.0
27 silly saveTree `-- electron@8.0.3
27 silly saveTree   +-- @electron/get@1.8.0
27 silly saveTree   `-- extract-zip@1.6.7
28 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...dMUeoccc6a4wqX100lsCT'
28 verbose stack     at JSON.parse (<anonymous>)
28 verbose stack     at parseJson (D:\Program\nodejs\node_modules\npm\node_modules\json-parse-better-errors\index.js:7:17)
28 verbose stack     at D:\Program\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\body.js:96:50
28 verbose stack     at processTicksAndRejections (internal/process/task_queues.js:97:5)
29 verbose cwd D:\electron-workplace\mianyang-demo
30 verbose Windows_NT 10.0.17763
31 verbose argv "D:\\Program\\nodejs\\node.exe" "D:\\Program\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "electron"
32 verbose node v12.16.1
33 verbose npm  v6.13.4
34 error Unexpected end of JSON input while parsing near '...dMUeoccc6a4wqX100lsCT'
35 verbose exit [ 1, true ]

这是因为npm自带的repository问题,改成另外一个repository地址:

npm config set registry https://registry.cnpmjs.org

再次执行安装命令:
 

npm install --save-dev electron

显示正常。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值