Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM Frontend Proxy Set, but Can't Download NPM Package

We are using the Eirslett Maven Frontend Plugin to help build our NPM projects in a standard way. This frontend takes care of installation and other issues for us. Plus, it allows our developers to build via mvn package just like they do with with our other Java/Maven projects.

This builds on my local machine with a proxy warning, but it won't build on our Jenkins server.

I have $HOME/.npmrc configured and both http_proxy and https_proxy environment variables set. Yet, I still get a no proxy is set error.

$ set | grep "http.?_proxy"
http_proxy=http://proxy.xxxx.local:3128
https_proxy=https://proxy.xxxx.local:3128

$ cat $HOME/.npmrc
registry = http://registry.npmjs.org/
proxy = http://proxy.xxxx.local:3128/
https-proxy = https://proxy.xxxx.local:3128/
strict = false
ca = null


$ mvn clean package
[...]
[INFO] --- frontend-maven-plugin:0.0.24:install-node-and-npm (install node and npm) @ ihcm-config-tool ---
[INFO] Installing node version v0.12.2
[INFO] Creating temporary directory /opt/tomcat/jenkins_home/jobs/ihcm-config-tool-trunk/workspace/node_tmp
[INFO] Downloading Node.js from \\  
       http://nodejs.org/dist/v0.12.2/node-v0.12.2-linux-x64.tar.gz \\  
       to /opt/tomcat/jenkins_home/jobs/ihcm-config-tool-trunk/workspace/node_tmp/node.tar.gz
[INFO] No proxy was configured, downloading directly
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.968 s
[INFO] Finished at: 2016-07-18T11:53:39-05:00
[INFO] Final Memory: 15M/303M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal \  
        com.github.eirslett:frontend-maven-plugin:0.0.24:install-node-and-npm \  
(install node and npm) on project ihcm-config-tool: Could not \   
download Node.js: Could not download \  
http://nodejs.org/dist/v0.12.2/node-v0.12.2-linux-x64.tar.gz: \  
Connect to nodejs.org:80 [nodejs.org/104.20.23.46, \
nodejs.org/104.20.22.46] failed: Connection refused -> [Help 1]

I can download http://nodejs.org/dist/v0.12.2/node-v0.12.2-linux-x64.tar.gz to my machine. I think the error may be the proxy, but I could be wrong. Anything I should be looking for?

like image 411
David W. Avatar asked Jul 18 '16 17:07

David W.


1 Answers

Found the problem.

The Eirslett Maven Frontend Plugin does not use $http_proxy or the proxy settings in the $HOME/.npmrc file. Instead, I had to put the proxy setting inside my $HOME/.m2/settings.xml file.

I created a special version of my settings.xml file with the added proxy settings (just to make sure that nothing is going to affect other projects). I created $HOME/.m2/settings.proxy.xml and then called Maven via mvn -s $HOME/.m2/settings.proxy.xml.

We use Artifactory which has its own proxy settings. We have configured NPM to use our Artifactory server for downloading. However, the Eirslett Maven Frontend Plugin can also install NodeJS too and Artifactory can't be set as the HOME of NodeJS.

We want the Eirslett Maven Frontend Plugin to install NodeJS if it's not already installed. This way, a new developer can get this project to build with just running mvn package much like they do with all of our other projects. Fortunately, the proxy isn't needed for the developers' machines. However, our Jenkins server is behind a corporate inner firewall and needs the proxy setup.

like image 54
David W. Avatar answered Oct 16 '22 09:10

David W.