无代理环境下npm安装React依赖报错ECONNREFUSED求助
Hey there, let's figure out why you're hitting this ECONNREFUSED error even in a proxy-free environment. The key clue here is that your npm is trying to connect to 127.0.0.1:8000 when requesting the npm registry—this means leftover proxy configurations are still forcing npm to route traffic through a local proxy that doesn't exist.
Here's how to resolve this step by step:
First, check your current npm configs
Run this command to see all active npm configurations:npm config listLook for entries like
proxy,https-proxy, orhttp-proxy—these are likely still set from a previous proxy environment.Clear leftover proxy settings
Delete any proxy-related configs with these commands:npm config delete proxy npm config delete https-proxy npm config delete http-proxyReset npm to use the official registry
Ensure your npm is pointing to the official registry (use HTTPS for better reliability):npm config set registry https://registry.npmjs.org/Check system environment variables
Sometimes proxy settings live in system environment variables. On Windows:- Open System Properties → Advanced → Environment Variables
- Look for
HTTP_PROXYorHTTPS_PROXYentries - Delete them if present, then restart your command prompt/terminal
Clear npm cache (if needed)
If you still run into issues, clear the npm cache to remove any stale data:npm cache clean --force
After completing these steps, try running your original install command again:
npm install webpack webpack-dev-server --save-dev
Why this happens
Even if you're in a proxy-free environment now, npm might still retain proxy configurations from past use. These settings force npm to send registry requests through a local proxy (127.0.0.1:8000 in your case) that isn't running, leading to the connection refused error.
内容的提问来源于stack exchange,提问作者prajwlr

