4

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 [email protected]
3 info using [email protected]
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

3
  • What is your node version. I'll suggest using 8.*.* or 10 Commented May 31, 2019 at 1:57
  • I am using version 8, tried 10 but had same problem so now using 8 Commented May 31, 2019 at 1:59
  • what worked for me was npm install --cache /tmp/empty-cache Got this from the error npm show when you run npm cache clean "As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use npm install --cache /tmp/empty-cache to use a temporary cache instead of nuking the actual one. If you're sure you want to delete the entire cache, rerun this command with --force" Commented Jun 13, 2020 at 8:50

6 Answers 6

8

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 
Sign up to request clarification or add additional context in comments.

Comments

3

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

2 Comments

Actually I was looking for a solution to overcome the error when I installed Expo-CLI on Mac, it turns out your answer helped me. Previously I got an error message like this: npm ERR! Unexpected end of JSON input while parsing near '...elfsigned":"^1.9.1","'
@wisnu Pramono, am glad my answer was helpful.
0

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

Comments

0

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.

Comments

0

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

1 Comment

Looks like part of your answer is missing.
0

I've resolved this issue in the following way:

npm cache clean --force

and

npm cache verify

then

npm i npm@latest -g

and finally, I was able to run

npm i

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.