React-native-windows: `react-native windows` does not work behind strict firewall

Created on 14 Nov 2016  路  8Comments  路  Source: microsoft/react-native-windows

When running the steps in the setup guide, react-native windows fails when reading data from the NPM registry when direct HTTPS access is unavailable.

As far as I can tell, there is no option to use a proxy server instead.

I have NPM working through a proxy with npm config set proxy and npm config set https-proxy, and can only set up react-native-windows by tampering with windows.js inside the rnpm-plugin-windows directory.

I've copied the full command-line output to this gist as I was having issues with multi-line markdown formatting.

All 8 comments

There's actually no real reason to use https here, would changing the script to use http work?

Nope, port 80 is also blocked on this network.

@yaakov-h if you have suggestions for what to use besides fetch for this step: https://github.com/ReactWindows/react-native-windows/blob/master/local-cli/rnpm/windows/src/windows.js#L39, it would be great if you could file a PR.

@rozele: You could use fetch (url, { agent: someHttpAgentObjectThatHasProxyOptionsSet }), but I don't know node/npm/react well enough to know how to get the proxy options from npm or somewhere else.

Facing the same issue here. Any update on this?
Here is an example of using proxy with node-fetch https://github.com/bitinn/node-fetch/issues/79#issuecomment-184594701

Update: I succeeded in running react-native windows command, by setting my proxy url to https_proxy environment variable, installing the https-proxy-agent to the base project and adding the following lines of code to windows.js file present within rnpm-plugin-windows node module.

const HttpsProxyAgent = require('https-proxy-agent');
const proxy = process.env.https_proxy;
const options  = {};
if(proxy){
  options.agent = new HttpsProxyAgent(proxy);
}

Use the options object as a second parameter to the fetch method.

return fetch('https://registry.npmjs.org/react-native-windows?version=latest', options)

Sounds like you figured it out -- care to submit a PR?

@matthargett I have raised a PR #963. Kindly check it out.

fixed by #963

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dubiao picture dubiao  路  3Comments

JunielKatarn picture JunielKatarn  路  3Comments

tahakhozooie picture tahakhozooie  路  4Comments

namrog84 picture namrog84  路  4Comments

fs-kanayama picture fs-kanayama  路  4Comments