I can install NativeScript via npm with no issues, but there is no way to configure the http-client with the proper proxy settings.
E:\LocalDev\nativescript>tns create hello-world --log trace
Starting watch on killswitch C:\Users\gabrielb\AppData\Local\Temp\gabrielb\KillSwitches\cli
Creating a new NativeScript project with name hello-world and id org.nativescript.helloworld at location E:\LocalDev\nativescript\hello-world
Using NativeScript hello world application
User-Agent: AppBuilderCLI/0.9.1 (Node.js 0.10.28; win32; x64)
httpRequest: { method: 'GET',
host: 'registry.npmjs.org',
port: null,
path: '/tns-template-hello-world',
headers:
{ Accept: 'application/json; charset=UTF-8, _/_;q=0.8',
'User-Agent': 'AppBuilderCLI/0.9.1 (Node.js 0.10.28; win32; x64)',
'Accept-Encoding': 'gzip,deflate' } }
httpRequest: Sending:
[nothing]
{ [Error: connect ETIMEDOUT] stack: [Getter] }
Error: connect ETIMEDOUT
Hi @briangabriel
It looks like there's a problem with the http-proxy. Could you try the suggestion from this blog post:
npm config set proxy http://proxy.company.com:8080 for example
Hopefully this will solve the issue.
I have no problems with npm, the issue is that the NodePackageManager.getAvailableVersions method calls the npm registry via a straight up HTTP request:
var url = NodePackageManager.NPM_REGISTRY_URL + packageName;
var response = this.$httpClient.httpRequest(url).wait().body;
Hi @briangabriel ,
You are absolutely correct. We are working on adding support for proxy, but meanwhile, can you try one more thing:
Can you try installing this custom package of nativescript-cli. Just download the file and execute:
$ npm i nativescript-0.9.1.tgz -g
After the installation finishes, find the place where nativescript is installed, open <nativescript-cli-dir>\lib\config.js and modify FIDDLER_HOSTNAME to match your proxy.
After that can you try creating new project and adding platforms, so we'll see if this works. Your help is appreciated.
One more thing, the package I've shared is created from this branch, so you can compare it with our latest release branch to see my changes - they are only in the config file.
Hi @briangabriel
In case you have problems with above link (its from dropbox), you can try this one - this time I've uploaded the package directly in github.
I've tried the version and it doesn't work for me, probably because the port is hard-coded to 8888 (the xxx.xxx.xxx.xxx is really the right IP address, just blanked). I've tried it with just the host IP address and with the IP address and port, the result for both is the same.
httpRequest: { method: 'GET',
host: 'xxx.xxx.xxx.xxx',
port: 8888,
path: 'http://registry.npmjs.org/tns-template-hello-world',
headers:
{ Host: 'registry.npmjs.org',
Accept: 'application/json; charset=UTF-8, */*;q=0.8',
'User-Agent': 'AppBuilderCLI/0.9.1 (Node.js 0.10.33; win32; x64)',
'Accept-Encoding': 'gzip,deflate' } }
httpRequest: Sending:
[nothing]
{ [Error: connect ECONNREFUSED] stack: [Getter] }
Error: connect ECONNREFUSED
Hi @Klors
You are correct, in the package I've prepared, the port is hardcoded. We've prepared a fix for this and it will be included in our next release. You can try it now by downloading this package and modifying <installation dir>\config\config.json file - just set USE_PROXY to be true and set your PROXY_HOSTNAME and PROXY_PORT. You can take a look at this issue where the problem had been widely discussed, but finally the solution was found.
That's great, I'll try it on Monday thanks.
That worked perfectly thanks
Thank you for testing it. As I've said - the same fix will be included in our next release. I'm closing this thread now, but feel free to contact us in case you have any other problems with the configuration.
I am having the same issue.
Tried the suggested solutions: added proxy to native script/config/config.json, set proxy on the command line....but none of them are fixing the problem... the command I am running is 'tns run android --device 1' and I am getting Downloading https://services.gradle.org/distributions/gradle-2.8-bin.zip
Exception in thread "main" java.net.ConnectException: Operation timed out
I'm having the same trouble as @vogatsiko - >tns run android gets to 'Preparing project... , Executing before-prepareJSApp hook.... Gradle clean... and as it attempts to download gradle-4.10.2-all.zip the connection times out. I've placed my proxy config in my gradle.properties file in my
systemProp.http.proxyHost=
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=
systemProp.https.proxyPort=8080
but even after restarting the CMD window still have this issue (Windows 10). I've searched a bit, but haven't found where gradlew would use a separate properties file though I see people refer to it. Just copying my gradle.properties didn't help, I guess because gradlew is supposed to run standalone apart from an existing install. It seems like poking proxy settings into project specific files is a bad solution though apparently the only way to do this presently?
Hey @datatribe ,
When setting the proxy in http.proxyHost and https.proxyHost, have you excluded the protocol, i.e. if the proxy is at 192.168.1.102, you'll have to put:
systemProp.http.proxyHost=192.168.1.102
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=192.168.1.102
systemProp.https.proxyPort=8080
I remember I've seen gradle failing in case you've added http:// in front of the IP, but probably it is not the case here.
What you can try is navigating to <project dir>/platforms/android and execute gradlew --stacktrace --debug and see if it will give you more information what's happening.
Thanks @rosen-vladimirov,
I was sure not to include http://. I tried your suggestion to debug and got some interesting results. The build failed the first two times with a lot of stack trace output, so I piped the output to a file and I noticed the behavior changed. It no longer said "build failed in 43 seconds".
I also have this line in my properties file, added by me as I was troubleshooting:
org.gradle.daemon=true
The build now concludes with the following:
12:04:42.072 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClient] Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'basicdemo'.] from daemon DaemonInfo{pid=21664, address=[69d069a9-e534-4a50-a64f-6c176bf40564 port:54499, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], state=Idle, lastBusy=1548953922535, context=DefaultDaemonContext[uid=e6798598-ed1c-4687-8376-b6cb8456ca10,javaHome=C:\Program Files\Java\jdk1.8.0_152,daemonRegistryDir=C:\Users\myid.gradle\daemon,pid=21664,idleTimeout=10800000,daemonOpts=-Xmx16384M,-Dfile.encoding=windows-1252,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be done).
Apparently piping to an output file isn't a good idea. I notice most of the visible output is missing.
Hey @datatribe ,
I'm not sure what might cause this error, it looks like gradle specific, maybe you can post your question in StackOverflow.
I've tried to search for similar errors, here's one link that might help: https://github.com/gradle/gradle/issues/2860
Also, have you tried cleaning your local gradle cache, the one at C:\Users\<username>\.gradle.
Also, does this happen when you try to build a pure JavaScript application created with CLI (i.e. tns create app1 --js).
I traced the problem to the ip address provided for our proxy server. Thanks for your help @rosen-vladimirov - you helped me pinpoint the issue.
I'm so glad you were able to trace the issue. Happy coding!