How to resolve npm error 'fetch_error' in Angular? - node.js

I have tried to inject angular dependency more and more time by applying this command but every time gets this attached error. If you have any solution please share. Thank you
npm cache clean --force
npm install
npm install --legacy-peer-deps
Angular, npm, node version like this...

npm cache clean --force
npm install -g #angular/cli#latest

Try to look up the registry, I change the registry as https://www.npmjs.com by mistake, change it as follow
npm config set registry https://registry.npmjs.org

My solution:
npm config set registry registry.npmjs.org
npm install or npm install --legacy-peer-deps

Related

npm ERR! Cannot read properties of null (reading 'pickAlgorithm')

iam getting below error with npm while creating react app
npm ERR! Cannot read properties of null (reading 'pickAlgorithm')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nagamanickam\AppData\Local\npm-cache_logs\2021-11-18T12_01_45_525Z-debug.log
my npm version is 8.1.4 and i solve this problem by running :
npm cache clear --force
I resolved it by deleting node_modules and package-lock.json and run npm install again.
solved with npm i --legacy-peer-deps on react-native version .70
Just run these 2 commands :
npm cache clear --force
npm install
Probably it's a project that works with Yarn and not NPM.
Try Yarn instead of NPM.
yarn install
and then you can do
yarn start
or
npm start
Your dependency tree may be broken (due to incompartible peer dependencies) you can try running npm install with --legacy-peer-deps or --force to bypass this issue for the mean time.
I was getting this error from an old branch that had a previous version of node/npm. using the correct version of node helped in my case.
In my case the file .npmrc was corrupt. After deleting it everything worked.
I was getting the same error, but I was able to resolve it by the below described method:
Go to folder -> Local > npm-cache and delete all contents of the npm-cache.
try again with npm command, it should work now.
I solved this by update npm from 6.x to 8.5x, then run npm cache clear --force, npm install, however, it has to change the nodejs from 14 to 17, my env is macOS m1 pro.
In my case i updated npm via:
npm update -g npm
After it, everything worked fine.
Don't know why, i didn't expect it.
I solved deleting node_modules and running this command:
npm cache clear --force

how do I resolve this node-sass installation error

npm ERR! Unexpected end of JSON input while parsing near '...--END PGP SIGNATURE--'
I keep getting this error while trying to install node-saas. I have even tried disabling anti-virus & windows defender.
I am using this command to install node sass:
npm install node-sass
Please check the below steps:
Please delete your package.lock.json file, along with that delete your node_modules folder.
Then clear all your npm cache by npm cache clean --force.
Install node-sass globally by using npm install -g node-sass
Once done with node-sass that run your npm install && npm start.
Hope this should work fine.

Not able to install express via npm [duplicate]

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
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:
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.
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.
if you check the first or the second, the structure is as follow
And each cache file have a json format (and that what get parsed)
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.
If
npm cache clean --force
doesn't work.
try
npm cache clean --force
npm update
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
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
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
None of the 30 answers here worked for me. I needed to:
delete node_modules and package-lock.json
npm cache clean --force
npm install -g #angular/cli
npm i --package-lock-only
npm ci
Phew!
this solved it npm cache clean --force
Simple solutions:
npm cache clean --force
npm install
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;
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
npm cache clean --force worked for me
Error Resolved :
$ npm install -g gulp
npm WARN deprecated gulp-util#3.0.8: 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
npm cache clean --force
For Windows : go to C:\Users\username\AppData\Roaming\npm-cache
Delete all files and run
npm install && npm start
I solved that by first cleaning the cache using
npm cache clean --force
Then
npm install -g #angular/cli
My case - Windows 7 (had nothing better at the needed moment).
Helped me the following:
Deleting everything from C:\Users\username\AppData\Roaming\npm-cache
AND
Deleting package-lock.json
I resolved my problem with this one liner
npm cache clean --force
Note: since its a clean install, I had no concerns emptying npm cache.
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
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.
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
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
If you looking for npm install and getting same kind of error
Delete package-lock.json and npm cache clean --force and try
In my case I changed the network to a much stronger one and npm install worked perfectly:
npm cache clean --force
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!
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.
For me I had to clone my branch again and do npm install
You can use yarn package manager instead of npm.
It solved this problem for me
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
These commands worked for me
sudo npm cache clean --force
sudo npm cache verify
sudo npm i npm#latest -g
Try setting
npm config set strict-ssl false
and then try running,
npm install -g #angular/cli
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

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

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
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:
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.
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.
if you check the first or the second, the structure is as follow
And each cache file have a json format (and that what get parsed)
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.
If
npm cache clean --force
doesn't work.
try
npm cache clean --force
npm update
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
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
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
None of the 30 answers here worked for me. I needed to:
delete node_modules and package-lock.json
npm cache clean --force
npm install -g #angular/cli
npm i --package-lock-only
npm ci
Phew!
this solved it npm cache clean --force
Simple solutions:
npm cache clean --force
npm install
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;
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
npm cache clean --force worked for me
Error Resolved :
$ npm install -g gulp
npm WARN deprecated gulp-util#3.0.8: 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
npm cache clean --force
For Windows : go to C:\Users\username\AppData\Roaming\npm-cache
Delete all files and run
npm install && npm start
I solved that by first cleaning the cache using
npm cache clean --force
Then
npm install -g #angular/cli
My case - Windows 7 (had nothing better at the needed moment).
Helped me the following:
Deleting everything from C:\Users\username\AppData\Roaming\npm-cache
AND
Deleting package-lock.json
I resolved my problem with this one liner
npm cache clean --force
Note: since its a clean install, I had no concerns emptying npm cache.
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
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.
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
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
If you looking for npm install and getting same kind of error
Delete package-lock.json and npm cache clean --force and try
In my case I changed the network to a much stronger one and npm install worked perfectly:
npm cache clean --force
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!
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.
For me I had to clone my branch again and do npm install
You can use yarn package manager instead of npm.
It solved this problem for me
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
These commands worked for me
sudo npm cache clean --force
sudo npm cache verify
sudo npm i npm#latest -g
Try setting
npm config set strict-ssl false
and then try running,
npm install -g #angular/cli
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

Installing npm package fails with 404

Using the command prompt, I am trying to install angular CLI and it fails. I have npm version 5.5.1 and node version v8.9.1. I am trying to install angular cli using the command
npm install -g #angular/cli#latest
and it fails with the error:
npm ERR! code E404
npm ERR! 404 Not Found: #angular/cli#latest
npm ERR! A complete log of this run can be found in:
I look at the log file and I see its trying to fetch the package from a location that doesn't exist. Not sure from where it gets pulled. How do I fix this location path and install angular cli. Same happens when I try to install typescript or any other npm package. all of them try to install from the location mentioned below and it fails with 404
8 http fetch GET 404
http://nuget.feed.xyz.corp:8729/npm/FeedNPM/#angular%2fcli 109ms
9 silly fetchPackageMetaData error for #angular/cli#latest 404 Not Found:
#angular/cli#latest
10 verbose stack Error: 404 Not Found: #angular/cli#latest
npm config set registry http://registry.npmjs.org
NPM registry documentation
Try first this commands (in windows run as administrator)
npm config set registry http://registry.npmjs.org
npm install -g #angular/cli
if still not working let's update NPM and nodejs by running this commands
npm -g install npm
npm cache clean -f
npm install -g n
then try to run
npm install -g #angular/cli
This should solve this problem
in my case it was .npmrc file in my project dir, which kept overwriting my global registry url. As soon as I deleted it, I could finally use npm install
Add a .npmrc file in the root of the project. .npmrc will look like below -
#xy:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/
#xy-app:registry=https://xyz.jfrog.io/xyz/api/npm/npm-local/
And Delete all the field eg - email , auth etc.
Find out what is the registry url of your application and put it into the registry.
Then run command - npm install
And it will work.
It was giving the same error for me when I use office network/vpn as they have 'umbrella' DNS security shield. To solve this issue, connect to personal network and type the below commands:
npm config set registry http://registry.npmjs.org
npm install -g #angular/cli
Alternative, another option to avoid 404 npm error
check if your terminal is in the root directory, if not your npm scripts will not execute
because it will not be able to see the package.json
I had same problem with a private package.
Need to:
npm adduser
npm login
I spent hours on this.
I had to follow the below steps to get it to work (mac).
Delete my LOCAL (not project) .npmrc by running:
rm /Users/<NAME>/.npmrc
Then set the registry:
npm config set registry https://registry.npmjs.org/
Then follow the steps for logging in to npm:
npm login
Check what's in your config list by running:
npm config list
It should look like this:
//registry.npmjs.org/:_authToken = (protected)
registry = "https://registry.npmjs.org/"
Hope it works for you too.
change your access level to public. type this in the terminal
npm --access=public
install your angular.
sudo npm install #ngular/cli
In my case, that's a typo error:
change trct-js-sdk to trtc-js-sdk saved my life.
My solution was as follows because I had a dependency on a private package. If you see the dependency in package.json defined in the format #scope/package, then #scope tells you that it's a scoped package that might be private.
Get the private package owner to grant you access to the package
Upgrade npm
Upgrade node
Add registry using HTTPS (not HTTP), e.g. npm config set registry https://registry.npmjs.org
Do "npm login"
Now run the build
Uninstall NPM & nodejs and install the right way NPM (Ubuntu)
sudo with npm is not recommended
To Uninstall
sudo apt-get remove nodejs
sudo apt-get remove npm
or
sudo apt-get purge nodejs
Followed by proper installation
curl -o-
https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
To confirm open a new terminal run:
$ command -v nvm
Latest LTS release of NodeJS:
$ nvm install --lts
Set default environment
$ nvm alias default lts/*
Worked for me
I got
error 404 'dotnev#*' is not in this registry.
Deleted .npmrc file in 2 folders back over my project root
and then in the project root folder typed:
npm i dotenv
copied from:
https://www.npmjs.com/package/dotenv
Just run sudo npm config set registry http://registry.npmjs.org and then update your npm.
It is an network error , check your network connection and try to install it again.
the only command line "npm -g install npm" solved the issue for me!
the following link can be helpful to dig deep for a better understanding.
Thanks a lot.

Resources