I keep getting a 403 Forbidden error whenever I try to run npm install in my project directory. This started happening after I had to reinstall everything on my computer.
npm WARN deprecated [email protected]: request has been deprecated
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported
npm ERR! code E403
npm ERR! 403 Forbidden: lodash@^4.17.21
npm ERR! Request to https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz failed
I’m using npm version 6.14.8 and Node.js v14.17.0. Everything was working fine before I had to format my machine and set up my development environment again.
The issue seems to affect all npm install attempts, not just specific packages. Here’s what I have in my .npmrc configuration:
I’ve tried different solutions but nothing seems to work. My password has special characters including ‘@’ which I’ve encoded as %40 in the configuration file.
Had this exact problem a few months ago on a new machine. 403 errors are usually proxy authentication issues.
Your encoded password looks right, but try a couple things. Switch to HTTPS:
registry=https://registry.npmjs.org/
Corporate proxies often block HTTP requests to npm.
Also encode any special characters in your username, and double-check your proxy server address is still correct.
Honestly though, npm proxy issues are a nightmare. I got tired of dealing with this manually and automated the whole thing.
I built a Latenode workflow that configures my dev environment automatically - handles proxy settings, sets up npm config based on whether I’m on corporate or home network. The workflow backs up working configs to cloud storage too, so new machines get everything restored without hunting down proxy settings or dealing with auth errors.
You could build something similar for your npm setup. Worth checking out: https://latenode.com
Sounds like a firewall issue - your corporate network’s probably blocking npm registry access. I hit the same thing when I switched jobs and had to fix my npm settings. First, update your npm version. Version 6.14.8 has proxy bugs, so jump to version 8 or higher. If that doesn’t work, try killing the proxy temporarily: run npm config delete proxy and npm config delete https-proxy to see if the install goes through. If it works without the proxy, you’ve got a config problem. Also check with IT - they might have a specific npm proxy setup you need to use.
check if your company changed the proxy port or server after u formatted - it updates break this stuff all the time. run npm config list to see what’s actually configured vs what u think is set. that http registry could be the problem too since most corporate firewalls now block http and only allow https.
Your proxy credentials probably expired after the reinstall. Corporate networks do this all the time - they kill passwords or need re-auth when you set up a new machine. I’ve seen tons of 403 errors that aren’t npm permission issues at all, just dead proxy auth. Hit your proxy server URL in a browser first. If it doesn’t work, grab fresh credentials from your network admin. Also check if your corporate proxy needs the domain prefix - like DOMAIN\username instead of just username. One more thing - run npm cache clean --force before you try again. Old cached auth tokens love to mess with new setups.