我对Ionic还是陌生的,我仍在尝试安装它。每次我写诸如npm install -g ionic cordova
之类的离子命令时,都会收到此错误
npm ERR! Unexpected end of JSON input while parsing near '...de":"0.6.2","express"'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\DwayneT\AppData\Roaming\npm-cache\_logs\2019-05-31T01_51_23_542Z-debug.log
'
这是我的日志文件
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli
'C:\\Users\\DwayneT\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-
cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'ionic',
1 verbose cli 'cordova' ]
2 info using npm@6.9.0
3 info using node@v8.11.1
4 verbose npm-session bf0a16c3729a6897
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 304 http://registry.npmjs.org/cordova 1407ms (from cache)
8 silly fetchPackageMetaData error for cordova@latest Unexpected end of JSON
input while parsing near '...de":"0.6.2","express"'
9 http fetch GET 304 http://registry.npmjs.org/ionic 1418ms (from cache)
10 silly pacote tag manifest for ionic@latest fetched in 1452ms
11 timing stage:rollbackFailedOptional Completed in 1ms
12 timing stage:runTopLevelLifecycles Completed in 1466ms
13 verbose stack SyntaxError: Unexpected end of JSON input while parsing
near '...de":"0.6.2","express"'
13 verbose stack at JSON.parse (<anonymous>)
13 verbose stack at parseJson
(C:\Users\DwayneT\AppData\Roaming\npm\node_modules\npm\node_modules\json-
parse-better-errors\index.js:7:17)
13 verbose stack at consumeBody.call.then.buffer
(C:\Users\DwayneT\AppData\Roaming\npm\node_modules\npm\node_modules\node-
fetch-npm\src\body.js:96:50)
13 verbose stack at <anonymous>
13 verbose stack at process._tickCallback
(internal/process/next_tick.js:188:7)
14 verbose cwd C:\Users\DwayneT
15 verbose Windows_NT 10.0.18362
16 verbose argv "C:\\Program Files\\nodejs\\node.exe"
"C:\\Users\\DwayneT\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-
cli.js" "install" "-g" "ionic" "cordova"
17 verbose node v8.11.1
18 verbose npm v6.9.0
19 error Unexpected end of JSON input while parsing near
'...de":"0.6.2","express"'
20 verbose exit [ 1, true ]
我尝试了许多解决方案,包括
npm cache clean --force
但似乎没有任何效果,我现在就在。请协助。我正在使用节点v 8
答案 0 :(得分:6)
这是npm缓存损坏的问题。您可以使用npm本身清除它。
我用
解决了npm cache clean --force
然后更新npm
npm i npm@latest -g
然后通常使用您的npm install命令
npm install
答案 1 :(得分:1)
尝试运行npm cache clean --force
,然后重新运行您的命令,希望此问题可以为您解决。
答案 2 :(得分:0)
尝试使用以下命令清理npm缓存。这将清除您现有的npm条目并从头开始。我认为一个文件在安装过程中可能已损坏,这就是您面临此问题的原因。
npm cache clean
然后尝试
npm install ionic -g
答案 3 :(得分:0)
我已经遇到了问题。 当您卸载Node js或删除npm全局软件包或在新机器上安装Node js时,将会发生错误。
请在安装npm install
或npm i
例如我的案例,我已经卸载了npm global软件包。当我安装npm install时,发生了错误。
答案 4 :(得分:0)
您应该通过以下操作手动清除npm缓存文件: C:\ Users [用户名] \ AppData \ Roaming \ npm-cache 更改[用户
答案 5 :(得分:0)
我已经通过以下方式解决了这个问题:
npm cache clean --force
和
npm cache verify
然后
npm i npm@latest -g
最后,我能够运行
npm i