NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'

node.jsAngularNpmNpm Install

node.js Problem Overview


When creating a new Angular 5 project:

node version: 8.9.2

npm version: 5.5.1

My Command is:

npm install -g @angular/cli

The Error is:

npm ERR! **Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'**
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Aashitec\AppData\Roaming\npm-cache\_logs\2017-12-06T13_10_10_729Z-debug.log

The error log is here

node.js Solutions


Solution 1 - node.js

This solved it for me:

Open Windows Powershell as admin

npm cache clean --force
npm install -g @angular/cli

https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/

Solution 2 - node.js

Solution:

npm cache clean --force

then try again to create your app (here when creating a react app) or install what you were about to install.

create-react-app myproject

(creating react app)[same npm problem that can occur in different operation]

npm install -g @angular/cli@latest

(installing angular cli (or installing anything else))

It will work.

explanation:

That's a problem related to npm, it's about the cache that get corrupt. Even though in newer versions of npm they implemented self healing, which normally guarantee no corruption, but it seem it's not that efficient. enter image description here Forcing clean cache resolve the problem.

The error happen when parsing one of the cache files, which have a json format. The cache is found at ~/.npm/_cacache (in linux) and %AppData%/npm-cache (windows). For my current npm version and when i checked, there was three directories.
enter image description here

if you check the first or the second, the structure is as follow enter image description here

And each cache file have a json format (and that what get parsed) enter image description here

Here a good link from the doc: https://docs.npmjs.com/cli/cache

[Update] Also if it happen that this didn't solve it, you may check this answer here https://stackoverflow.com/a/50191315/7668448 it show how you can change the npm registry, that can be helpful. Check and see.

Solution 3 - node.js

If

npm cache clean --force

doesn't work. try

npm cache clean --force
npm update

Solution 4 - node.js

Npm uses Cache for downloading new packages for you. You need to clear your npm cache. use following command to clean :

npm cache clean --force

then normally use your npm install command e.g.

npm install -g @angular/cli

Solution 5 - node.js

I solve that with

npm cache clean --force

then update npm

npm i npm@latest -g

then normally use your npm install command

npm install 

Solution 6 - node.js

delete npm and npm-cache folders in C:\Users\admin\AppData\Roaming\ (windows) then execute cmd >npm cache clear --force

>npm cache verify

update npm to latest version >npm i -g npm

then create your project 1)Angular >npm i -g @angular/cli@latest

>ng new HelloWorld

2)React >npm i -g create-react-app

>create-react-app react-app

Solution 7 - node.js

None of the 30 answers here worked for me. I needed to:

  1. delete node_modules and package-lock.json
  2. npm cache clean --force
  3. npm install -g @angular/cli
  4. npm i --package-lock-only
  5. npm ci

Phew!

Solution 8 - node.js

this solved it npm cache clean --force

Solution 9 - node.js

Simple solutions:

npm cache clean --force
npm install 

Solution 10 - node.js

npm cache clean --force worked for me

Error Resolved :

$ npm install -g gulp npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 npm ERR! Unexpected end of JSON input while parsing near '.../RGs88STtAtiMP3tCiNdU'

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\admin\AppData\Roaming\npm-cache_logs\2018-11-20T07_38_56_733Z-debug.log

Solution 11 - node.js

This command alone solved my problem:

npm cache clean --force

Also you should make sure you are using the correct version of node.

Using nvm to manage the node version:

nvm list; # check your local versions;
nvm install 10.10.0; # install a new remote version;
nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;

Solution 12 - node.js

I use Windows and removed all the files that were listed below and my problem was solved C:\Users{{your-username}}\AppData\Roaming\npm-cache

Solution 13 - node.js

Solution

npm cache clean --force

For Windows : go to C:\Users\username\AppData\Roaming\npm-cache
Delete all files and run

npm install && npm start

Solution 14 - node.js

I solved that by first cleaning the cache using

npm cache clean --force

Then

npm install -g @angular/cli

Solution 15 - node.js

My case - Windows 7 (had nothing better at the needed moment). Helped me the following:

  1. Deleting everything from C:\Users\username\AppData\Roaming\npm-cache

AND

  1. Deleting package-lock.json

Solution 16 - node.js

It's simple

npm cache clean --force

then install node dependencies by

npm install

Solution 17 - node.js

I resolved my problem with this one liner

npm cache clean --force

It works like a charm all the time. I love one liners. Note: since its a clean install, I had no concerns emptying npm cache.

Solution 18 - node.js

> ERROR: npm ERR! Unexpected end of JSON input while parsing near '...ore-js":"3.0.0-beta.1

This occurs when installing the expo CLI globally, This works for me!

npm cache clean --force

Solution 19 - node.js

I got error (file already exists --force to overwrite) after running the following code:

npm cache clean --force
npm install -g @angular/cli

I solved it using :

npm i -g --force npm

Make sure to run the first commands to flush the cache of npm.

Solution 20 - node.js

npm cache clean --force
npm update

Do not forget to do "npm update". it is very important step .

Solution 21 - node.js

It's error from your npm....

So unistall node and install it again.

It works....

PS: After installing node again, install angular cli globally.

npm install -g @angular/cli@latest

Solution 22 - node.js

I solve that with

> First delete package-lock.json

npm cache clean --force

then update npm

npm i npm@latest -g

then use npm install command

npm install 

Solution 23 - node.js

You can use yarn package manager instead of npm.

It solved this problem for me

Solution 24 - node.js

If npm cache clean --force doesn't resolve the issue, try deleting the ~/.npm directory (*nix/macOS). This is the directory where node stores its cache, locks, logs, global packages (unless you're using nvm), and modules installed via npx.

First, backup your current ~./npm directory:

mv ~/.npm ~/.npm-backup

Now try running your npm command again. This will create a new ~/.npm directory. If the issue is resolved, you can safely remove you backup. Before doing so, you may want to review the global packages installed in your ~/.npm-backup directory so you can reinstall them using npm i -g [package].

rm -rf ~/.npm-backup

If the issue is not resolved, you can restore your backup:

rm -rf ~/.npm
mv ~/.npm-backup ~/.npm

Careful with those rm commands, folks!

Solution 25 - node.js

If you looking for npm install and getting same kind of error

Delete package-lock.json and npm cache clean --force and try

Solution 26 - node.js

In my case I changed the network to a much stronger one and npm install worked perfectly:

npm cache clean --force

Solution 27 - node.js

Instead of clearing the cache you can set a temporary folder:

npm install --cache /tmp/empty-cache

or

npm install --global --cache /tmp/empty-cache

> 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.

Solution 28 - node.js

For me I had to clone my branch again and do npm install

Solution 29 - node.js

I've faced this issue and I tried all the answers on Stackoverflow but not worked for me, finally I found solution for this issue:

  • First of all you have to uninstall nodejs and remove all the files related him
  • Go to "Register Editor" and search for all "nodejs", "node.js" and delete them
  • Restart your computer
  • And reinstall nodejs then install angular.

It's worked for me

Solution 30 - node.js

These commands worked for me

sudo npm cache clean --force

sudo npm cache verify

sudo npm i npm@latest -g

Solution 31 - node.js

Try setting

npm config set strict-ssl false

and then try running,

npm install -g @angular/cli

Solution 32 - node.js

This happens something due to cache or outdated version of Node Package Manager i just updated my NPM it works fine here is command to update Npm to latest version

npm i npm@latest -g

after updating NPM run your desired command

Solution 33 - node.js

Even if npm cache clean --force

> Try to execute the installing cmd in admin folder.
i.e > C:\Users\admin
This worked out for me.

Solution 34 - node.js

Just faced the issue of Unexpected end of JSON input while parsing near.. while adding the 'radium' package in my React App. As a matter of fact, I am facing this issue even when trying to update the NPM to the latest version.

Anyways, NPM didn't work after clearing the cache and it also won't update to the latest version right now but adding the package via Yarn did the trick for me.

So, if you are in a hurry to solve this issue but you are not able to, then give yarn a try instead of npm.

Happy Coding!

Update

After trying few things finally sudo npm cache clean --force worked for me.

This can be a temporary glitch in your network or with something else in the npm registry.

Solution 35 - node.js

npm uninstall -g angular-cli

npm cache clear --force

OR

Delete this folder directory (In Windows)

rmdir C:\Users\<ProfileName>\AppData\Roaming\npm
rmdir C:\Users\<ProfileName>\AppData\Roaming\npm-cache

Solution 36 - node.js

Firstly uninstall the existing npm package: npm uninstall -g create-react-app (-g if you installed globally) Secondly: npm cache clean --force Thirdly: npm install -g create-react-app@latest and create-react-app my-app again.

Solution 37 - node.js

> This bug may be caused by many different things.Maybe your global packages are corrupted in some way, I suggest doing the following.

1 Install Node Version Manager (or NVM for Windows) and install Node version 10.16.1. This is enough for angular 9 and from my experience, it is the most stable version for development. This should also change your NPM version so that may also help.

2 Uninstall global angular package npm uninstall -g @angular/cli

3 Force clear cache npm cache clean --force

4 You can also try clearing your %temp% and %roaming% AppData/npm-cache

5 install latest angular package npm install -g @angular/cli@<your-version>

6 if this error still occurs, consider using another shell.

> Source- https://www.codegrepper.com/code-examples/javascript/npm+ERR%21+Unexpected+end+of+JSON+input+while+parsing+near+%27...babel-plugin-istanbul%27+npm+ERR%21+A+complete+log+of+this+run+can+be+found+in%3A+npm+ERR%21+C%3A%5CUsers%5Csapho%5CAppData%5CRoaming%5Cnpm-cache%5C_logs%5C2020-08-26T20_37_45_303Z-debug.log+Aborting+installation.

Solution 38 - node.js

Open windows PowerShell or CMD as admin

npm cache clean --force
npm install -g @angular/cli

> If this didn't work try the following

npm cache clean --force
npm update
npm install -g @angular/cli

Solution 39 - node.js

After this npm cache clean --force

may be you can hangup or waiting for further execution

> npm WARN using --force I sure hope you know what you are doing.

So you can also use this one. This resolve my issue.

> npm install --cache /tmp/empty-cache

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkathirView Question on Stackoverflow
Solution 1 - node.jsmcemmyView Answer on Stackoverflow
Solution 2 - node.jsMohamed AllalView Answer on Stackoverflow
Solution 3 - node.jsMD SHAYONView Answer on Stackoverflow
Solution 4 - node.jsAmit GaikwadView Answer on Stackoverflow
Solution 5 - node.jsHasibul-View Answer on Stackoverflow
Solution 6 - node.jsRavinder Reddy KottabadView Answer on Stackoverflow
Solution 7 - node.jsChristopher GriggView Answer on Stackoverflow
Solution 8 - node.jsBIS TechView Answer on Stackoverflow
Solution 9 - node.jsShashwat GuptaView Answer on Stackoverflow
Solution 10 - node.jsuser10680309View Answer on Stackoverflow
Solution 11 - node.jsHearenView Answer on Stackoverflow
Solution 12 - node.jsmilad karimiView Answer on Stackoverflow
Solution 13 - node.jsmahendraView Answer on Stackoverflow
Solution 14 - node.jsDesire KalebaView Answer on Stackoverflow
Solution 15 - node.jsysvetView Answer on Stackoverflow
Solution 16 - node.jsMohit RakhadeView Answer on Stackoverflow
Solution 17 - node.jspasignatureView Answer on Stackoverflow
Solution 18 - node.jsLahiru AmarathungeView Answer on Stackoverflow
Solution 19 - node.jsRijoView Answer on Stackoverflow
Solution 20 - node.jssoni kumariView Answer on Stackoverflow
Solution 21 - node.jsraghu rkmView Answer on Stackoverflow
Solution 22 - node.jsMuhammad TahirView Answer on Stackoverflow
Solution 23 - node.jsVahid KhView Answer on Stackoverflow
Solution 24 - node.jsjhildenbiddleView Answer on Stackoverflow
Solution 25 - node.jsOverflowrunView Answer on Stackoverflow
Solution 26 - node.jsAfuye OlawaleView Answer on Stackoverflow
Solution 27 - node.jsGianfranco P.View Answer on Stackoverflow
Solution 28 - node.jsmtchuenteView Answer on Stackoverflow
Solution 29 - node.jsMohamad AlhamidView Answer on Stackoverflow
Solution 30 - node.jsZohab AliView Answer on Stackoverflow
Solution 31 - node.jsMano Prakash PView Answer on Stackoverflow
Solution 32 - node.jsHanzla HabibView Answer on Stackoverflow
Solution 33 - node.jsLSTView Answer on Stackoverflow
Solution 34 - node.jsRupakView Answer on Stackoverflow
Solution 35 - node.jsParthasarathy SView Answer on Stackoverflow
Solution 36 - node.jsUsman Ahmed ManiView Answer on Stackoverflow
Solution 37 - node.jsUtkarsh SinghView Answer on Stackoverflow
Solution 38 - node.jsLoop AssemblyView Answer on Stackoverflow
Solution 39 - node.jsBalwant SinghView Answer on Stackoverflow