Use create-react-app behind corporate firewall

there is any way for work with create-react-app behind corporate firewall by setting a proxy.

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:reactmy-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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I had been struggling with this for weeks. What worked for me was to include –use-npm at the end of the command and finally I got rid of the “no lockfile found” error. I sincerely hope this helps someone else struggling with the same issue.

Method 2

I have had this issue as well, and I solved this with this command:

create-react-app hello-world --use-npm --cache /tmp/empty-cache

Method 3

As a workaround, try first running yarn add react react-dom react-scripts in an empty folder. This will add the required packages to yarn’s local cache. You can then delete that folder and run create-react-app my-app again and it will hopefully work.

Method 4

Update: Looks like this bug has now been fixed, and should no longer be present in version 1.1.0.


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

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.

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

Method 5

These settings solved it for me:

npm config set proxy http://username:<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c8b8a9bbbbbfa7baac88a0a7bbbc">[email protected]</a>:port
npm config set https-proxy http://username:<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4333223030342c3127032b2c3037">[email protected]</a>:port

Method 6

This solved my problem – See details
npm config set registry "https://registry.npmjs.org"


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x