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
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!
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
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/
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;
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!
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.
My case - Windows 7 (had nothing better at the needed moment). Helped me the following:
AND