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 [email protected]
3 info using [email protected]
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 [email protected] 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/[email protected] 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 [email protected] checking installable status
25 timing stage:rollbackFailedOptional Completed in 0ms
26 timing stage:runTopLevelLifecycles Completed in 1681ms
27 silly saveTree [email protected]
27 silly saveTree `-- [email protected]
27 silly saveTree   +-- @electron/[email protected]
27 silly saveTree   `-- [email protected]
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

显示正常。

猜你喜欢

转载自blog.csdn.net/eclothy/article/details/104647364