在企业防火墙后面使用 create

编程入门 行业动态 更新时间:2024-10-22 23:13:54
本文介绍了在企业防火墙后面使用 create-react-app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有任何方法可以通过设置代理在企业防火墙后面使用 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 yarnpkg/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:github/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: github/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=my.corporate.proxy create-react-app my-new-project

更多推荐

在企业防火墙后面使用 create

本文发布于:2023-06-11 17:28:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/639754.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:防火墙   企业   create

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!