安装Stencil CLI/Framework报错:无法连接github.com
It sounds like npm is hitting a snag when trying to interact with Git during the Stencil CLI installation—this is usually tied to Git configuration or proxy quirks on Windows. Let’s walk through targeted fixes to get this sorted:
1. Enable Git's Long Paths Globally
Windows has a default limit on file path lengths, which can break Git operations during package installs. The error mentions core.longpaths=true, so let’s set this globally to avoid per-command issues:
git config --global core.longpaths true
After running this, retry the install command:
npm install -g @bigcommerce/stencil-cli
2. Double-Check Git's Proxy Configuration
Even if you’ve set up npm’s proxy, Git needs its own proxy settings to access remote repositories. In Git Bash, configure your proxy for both HTTP and HTTPS:
# Replace <proxy-url:port> with your actual proxy details git config --global http.proxy http://<proxy-url:port> git config --global https.proxy https://<proxy-url:port>
If your proxy requires authentication, include your credentials:
git config --global http.proxy http://<username>:<password>@<proxy-url:port> git config --global https.proxy https://<username>:<password>@<proxy-url:port>
Verify your settings with:
git config --global --get http.proxy git config --global --get https.proxy
3. Clear npm's Cache
Corrupted cached data can sometimes cause unexpected errors. Clear the npm cache and try the install again:
npm cache clean --force npm install -g @bigcommerce/stencil-cli
4. Run Git Bash as Administrator
Windows permission restrictions might block Git from accessing certain configuration files. Right-click Git Bash and select "Run as administrator", then execute the install command again.
5. Verify Git is in Your System PATH
Ensure Git’s executable directory is added to your system PATH so npm can call it correctly:
- Open System Properties > Advanced > Environment Variables
- Under "System Variables", find the
PATHentry and check if it includesC:\Program Files\Git\bin(or your Git installation directory) - If not, add it, restart your terminal, and retry the install.
6. Test Without Proxy (If Possible)
If you have access to a network without a proxy, try installing Stencil CLI there. This will help confirm if the proxy is the root cause of the issue.
内容的提问来源于stack exchange,提问作者ijason03

