在企业防火墙后面使用 create-react-app [英] Use create-react-app behind corporate firewall
问题描述
有任何方法可以通过设置代理在企业防火墙后面使用 create-react-app
.
there is any way for work with create-react-app
behind corporate firewall by setting a proxy.
我已经在 npm 和 yarn 上设置了代理,但这是我在尝试 create-react-app my-app
时看到的:
i have setted the proxy on npm and yarn, but this is what i see when try to create-react-app my-app
:
Creating a new React app in F:\react\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
You appear to be offline.
Falling back to the local Yarn cache.
yarn add v0.23.4
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find any versions for "react" that matches "latest" in our cache. Possible versions: ""
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation.
yarnpkg add --exact --offline react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting my-app / from F:\react
Done.
推荐答案
更新: 看起来这个 bug 有 现已修复,并且不应再出现在 1.1.0 版.
Update: Looks like this bug has now been fixed, and should no longer be present in version 1.1.0.
这个问题是由以下事实引起的,即纱线注册表在反应脚本中硬编码到 registry.yarnpkg.com
:https://github.com/facebookincubator/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L692
This problem is caused by the fact that the yarn registry is hard-coded in react-scripts to registry.yarnpkg.com
: https://github.com/facebookincubator/create-react-app/blob/master/packages/create-react-app/createReactApp.js#L692
根据此拉取请求,如果纱线注册表是无法访问,然后 它会检查看你是否设置了https_proxy
环境变量,如果是的话,它会验证那个服务器是可访问的,而不是硬编码纱线注册表.
As per this pull request, if the yarn registry is not reachable, then it will check to see if you have the https_proxy
environment variable set, and then if so it will verify that that server is reachable, instead of the hard-coded yarn registry.
重申一下,在 npm/yarn 中设置 proxy/https-proxy 配置是不够的 - 您还需要设置 https_proxy
环境变量,因为这是 create-react-app 将检查的在确定您是否在线时.例如:
To reiterate, it's not enough to set the proxy/https-proxy configs in npm/yarn - you also need to set the https_proxy
environment variable, because that's what create-react-app will check when determining if you are online. For example:
https_proxy=https://my.corporate.proxy create-react-app my-new-project
这篇关于在企业防火墙后面使用 create-react-app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!