npm ERR! Unexpected end of JSON input while parsing near '…registry.npmjs.org/@i'

僤鯓⒐⒋嵵緔 提交于 2020-07-19 05:15:11

问题


I am new to ionic and i am still trying to install it. Everytime i write an ionic command like npm install -g ionic cordova i receive this error

    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

'

this is my log file

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 ]

I have tried many solutions including

npm cache clean --force

but nothing seems to work and i am now now. Kindly assist please. I am using node v 8


回答1:


It is the problem with npm corrupt caches. You can clear it using npm itself.

I solved it with

npm cache clean --force

then update npm

npm i npm@latest -g

then normally use your npm install command

npm install 



回答2:


Try run npm cache clean --force then re-run your command, I hope this fix this issue for you.




回答3:


Try cleaning the npm cache use the below command. This will clean your existing npm entries and start from the beginning. I think the one file may be corrupt during the installation that's why you are facing this issue.

npm cache clean  

Then try

npm install ionic -g



回答4:


I've faced the problem. when you uninstalled node js or delete the npm global packages or install the node js in a new machine that error will have occurred.

Please install global npm packages after installing the npm install or npm i

For Example My Case I've uninstalled npm global package. When I installed npm install, an error occurred.




回答5:


You should clear the npm cache files manually by going to C:\Users[Username]\AppData\Roaming\npm-cache change [user



来源:https://stackoverflow.com/questions/56387743/npm-err-unexpected-end-of-json-input-while-parsing-near-registry-npmjs-org

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!