I\'ve been desperately trying to install modules using node.js but it always fails getting packages with npm.
I logged in as Administrator and used powershell/cmd wi
Here is how I fixed the problem in Windows. I was trying to install the CLI for Angular.
Turn off firewall and antivirus protections.
Right click the nodejs folder (under Program Files), select Properties (scroll all the way down), click the Security tab, and click all items in the ALLOW column (for All System Packages and any user or group that allows you to add the “allow” checkmark).
Click the Windows icon. Type cmd. Right click the top result and select Run as Administrator. A command window results.
Type npm cache clean. If there is an error, close log files or anything open and rerun.
Type npm install -g @angular/cli (Or whatever npm install command you are using)
Check the installation by typing ng –version (Or whatever you need to verify your install)
Good luck! Note: If you are still having problems, check the Path in Environmental Variables. (To access: Control Panel → System and Security → System → Advanced system settings → Environment variables.) My path variable included the following: C:\Users\Michele\AppData\Roaming\npm
I had the same problem and I've fixed the error by cleaning the cache:
npm cache clean -f
FINALLY Got this working after 4 hours of installing, uninstalling, updating, blah blah.
The only thing that did it was to use an older version of node v8.9.1 x64
This was a PC windows 10.
Hope this helps someone.
Deleting the global npm-cache and/or running my cmd line as admin did not work for me. Also, as of npm version 5.x.x, it supposedly recovers from cache corruption by itself.
This did work:
1. Deleted the node_modules folder in my current project.
2. Deleted the package-lock.json in my current project
3. Installed the new package. In my case: npm install bootstrap@next --save
4. Ran npm install
for my current project.
Everything now works. In general, nuking node_modules and package-lock.json usually fix these "no apparent reason" bugs for me.
I just had the same problem again. But I noticed that everything was installed correctly even though it threw the error after I had followed the steps outlined above. So I could just run ng serve
(for Angular), and everything worked.
This sure is a weird error...
Like the other answers, clean npm cache and make sure the cache folder is empty, then run npm install several times. Each time the error message comes for different packages, and the final time (after X attempts) it succeeds.
npm clean cache --force
cd %APPDATA%\npm-cache
(or cd $env:APPDATA\npm-cache
for PowerShell)del *
to delete everything in the foldernpm install
several times until it succeeds. Notice that the error messages come for different packages every time.As a hack,
Check if the folder path it is complaining exists or not. If not, try creating them manually and rerun the installation, after clearing the cache
I had success with this, when running the installation from command prompt as an Administrator didn't work