I wanted to run npm install from within my external hard drive as this is where i saved my code workspace. Windows 10 OS.
But I was getting the same error as the original post.None of the previous answers worked for me, I tried all of them:
- uninstalling nodejs then re-installing
- uninstalling nodejs then downgrading/installing a lower version of nodejs.
- npm install -force
- deleting the folders from C:\Users{YourUsername}\AppData\Roaming ... npm and npm-cache then re-installing.
- npm cache clean --force
- npm cache clean
- npm install --g or npm install --global
What worked for me was this:
- copy the folder from C:\Program Files\nodejs to D:\Program Files\nodejs
- Then go to Control Panel\System and Security\System
- Advanced System Settings
- Environment Variables
- System Variables
- Double click Path
- Add a new path
- D:\Program Files\nodejs
- Click ok
- restart PC.
- try npm install from within D: Drive