5

Command:

npm install -g @angular/cli@latest

Exception:

verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...ge-2.2.1.tgz"},"engin' 169 verbose stack at JSON.parse () 169 verbose stack at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17) 169 verbose stack at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50) 169 verbose stack at 169 verbose stack at process._tickCallback (internal/process/next_tick.js:188:7)


Looking for help and support. Thanks

dhilt
  • 18,707
  • 8
  • 70
  • 85
Arvind Gautam
  • 51
  • 1
  • 1
  • 6

6 Answers6

13
npm cache clean --force 

Then :

npm install -g @angular/cli

If not working :

Delete package.lock.json file and try again

willmaz
  • 2,376
  • 1
  • 20
  • 24
1

I started facing this issue after upgrading npm package.

You can resolve this with: npm cache clean --force

voila, reinstall the package.

Prasanna Jathan
  • 570
  • 7
  • 12
0

Curious how that error happen, look at my answer here, that explain that well https://stackoverflow.com/a/52249619/7668448

You will quickly understand. I put some nice images to illustrate the thing. Hope that was helpful.

Mohamed Allal
  • 17,920
  • 5
  • 94
  • 97
0

Just in case someone else ends up here and the above answers don't work for them I found after hours of fiddling that downgrading my npm from version 5 to version 4 did the trick:

npm install -g npm@4

After which I closed my CMD and opened it again and was able to install the Angular CLI with the normal command:

npm install -g @angular/cli

Hope this helps someone along the way, cheers!

Daefect91
  • 128
  • 8
0

I am using :

  • node v12.17.0
  • npm 6.14.4
  • Windows 10

I was trying to install Amplify 4.21.0 when I faced:

Error Unexpected end of JSON input while parsing near ....

It worked for me after doing the following steps:

  • Uninstall and reinstall node.
  • Delete the files in C:\Users\username\AppData\Roaming\npm-cache
  • Using the command line as administrator, I run npm cache clean --force
  • I deleted the package.lock.json file in C:\Users\username.
  • Then installed Amplify using npm install -g @aws-amplify/cli
Nimantha
  • 6,405
  • 6
  • 28
  • 69
M.z
  • 51
  • 5
0
npm cache clean --force

after you've finished running the code above then try installing angular again npm install -g @angular/cli