-2

while installing angular/cli using npm I am getting below error. I even tried reinstalling node.js and tried to install angular cli through below commands

npm install -g @angular/cli

also tried

npm install @angular/cli@latest -g 

but still same error is popping up.

C:\Users\USER>npm install @angular/cli@latest -g
npm ERR! Unexpected end of JSON input while parsing near '...":{"babel-polyfill":"'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\USER\AppData\Roaming\npm-cache\_logs\2020-10-14T19_32_16_080Z-debug.log

enter image description here

James Z
  • 12,209
  • 10
  • 24
  • 44
Praveen L
  • 79
  • 1
  • 1
  • 6
  • Does this answer your question? [NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'](https://stackoverflow.com/questions/47675478/npm-install-errorunexpected-end-of-json-input-while-parsing-near-nt-webpack) – Tomer Shetah Oct 15 '20 at 12:54

3 Answers3

3

my problem is finally solved - installation of angular/cli successful.

Run the following command in cmd promt :

  1. npm cache verify
    --> run the command in cmd which verify your NPM cached memory.
  2. npm cache clear --force --> it will be cleaning your NPM cache memory.
  3. npm install –g @angular/cli@latest --> now tried installing with this command
  4. ng --version --> to check the installed version of angular.

Thanks to all guys..

Praveen L
  • 79
  • 1
  • 1
  • 6
0

Check if your package.json is a valid JSON. Quite probable that you have an extra or a missing comma.

  • Thank for your reply Aram, how do I get to know that its a valid JSON. Actually I am new to angular, just starting.. please clarify..I'll try.. – Praveen L Oct 15 '20 at 06:47
  • Try online tools for validating JSON (in case your IDE is not capable of doing it), e.g. https://jsonformatter.org. Put all your JSON files there and ensure they all are valid. – Aram Khachatrian Oct 15 '20 at 07:14
  • ok Aram I'll try.. thanks and I got the solution for my question which I posted, please check it once. thanks for your valuable reply.. – Praveen L Oct 15 '20 at 07:22
0

This is probably because of a corrupt file in your cached node modules file.

Try below;

Run npm install -g @angular/cli --force. This should force a new installation of the package

Owen Kelvin
  • 14,054
  • 10
  • 41
  • 74
  • thanks for your reply.. I tried, but this command also not working, still the same error I am getting.. – Praveen L Oct 15 '20 at 06:41