eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.26k stars 872 forks source link

npm install phantomjs-prebuillt ignoring phantomjs_cdnurl on Unix #847

Open toschder opened 5 years ago

toschder commented 5 years ago

Do you want to request a feature or report a bug? I guess it´s a bug? What is the current behavior? I have configured the frontend-maven-plugin to download and install npm, node and phantomsjs-prebuilt. It´s working on Windows - but fails on my Jenkins Slave (Unix) which has no proxy set and seems to ignore the _phantomjscdnurl.

If the current behavior is a bug, please provide the steps to reproduce. Here´s my pluginManagement from my pom.xml:

        <plugin>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.8.0</version>

            <configuration>
                <nodeVersion>v8.10.0</nodeVersion>
                <npmVersion>5.8.0</npmVersion>
                <installDirectory>target</installDirectory>
        <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
                <nodeDownloadRoot>https://nexus.mycompany.net/repository/mycompany_raw_repositories/</nodeDownloadRoot>
                <npmDownloadRoot>https://nexus.mycompany.net/repository/mycompany_npm_repositories/npm/-/</npmDownloadRoot>
            </configuration>
        </plugin>               
    </plugins>
</pluginManagement>

And this are the executions:

<plugin>
    <groupId>com.github.eirslett</groupId>
    <artifactId>frontend-maven-plugin</artifactId>

    <executions>
        <execution>
            <id>install node and npm</id>
            <goals>
                <goal>install-node-and-npm</goal>
            </goals>
        </execution>

        <execution>
            <id>npm config</id>
            <goals>
                <goal>npm</goal>
            </goals>

            <phase>generate-resources</phase>

            <configuration>
                <!-- https://nexus.mycompany.net/repository/npm_registry/phantomjs/-/ -->
                <arguments>config set phantomjs_cdnurl https://bitbucket.org/ariya/phantomjs/downloads --verbose</arguments>
            </configuration>
        </execution>

        <execution>
            <id>npm config list</id>
            <goals>
                <goal>npm</goal>
            </goals>

            <phase>generate-resources</phase>

            <configuration>
                <arguments>config list --json</arguments>
            </configuration>
        </execution>

        <execution>
            <id>npm install phantomjs</id>
            <goals>
                <goal>npm</goal>
            </goals>

            <phase>generate-resources</phase>

            <configuration>
                <arguments>install phantomjs-prebuilt --verbose</arguments>
            </configuration>
        </execution>

What is the expected behavior? The expected behaviour is that it will download phantomjs-2.1.x.tgz on Unix from the configured phantomjs_cdnurl. On Windows (locally) I´m getting

...
[INFO] --- frontend-maven-plugin:1.8.0:npm (npm install phantomjs) @ pconfserv-poc-ui ---                                                                                                             
[INFO] npm not inheriting proxy config from Maven                                                                                                                                                     
[INFO] Running 'npm install phantomjs-prebuilt --verbose' in D:\Projekte\PCONFSERV\pconfserv_poc_ui                                                                                                   
[INFO] npm info it worked if it ends with ok                                                                                                                                                          
[INFO] npm verb cli [ 'D:\\Projekte\\PCONFSERV\\pconfserv_poc_ui\\target\\node\\node.exe',                                                                                                            
[INFO] npm verb cli   'D:\\Projekte\\PCONFSERV\\pconfserv_poc_ui\\target\\node\\node_modules\\npm\\bin\\npm-cli.js',                                                                                  
[INFO] npm verb cli   'install',                                                                                                                                                                      
[INFO] npm verb cli   'phantomjs-prebuilt',                                                                                                                                                           
[INFO] npm verb cli   '--verbose' ]                                                                                                                                                                   
[INFO] npm info using npm@5.8.0                                                                                                                                                                       
[INFO] npm info using node@v8.10.0
--
...

[INFO] PhantomJS not found on PATH                                                                                                                                                                    
[INFO] Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-windows.zip                                                                                                        
[INFO] Saving to C:\Users\xreit2\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip                                                                                                             
[INFO] Receiving...                                                                                                                                                                                   
[INFO]                                                                                                                                                                                                
[INFO] Received 17767K total.                                                                                                                                                                         
[INFO] Extracting zip contents                                                                                                                                                                        
[INFO] Removing D:\Projekte\PCONFSERV\pconfserv_poc_ui\node_modules\phantomjs-prebuilt\lib\phantom                                                                                                    
[INFO] Copying extracted folder C:\Users\xreit2\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip-extract-1568300503127\phantomjs-2.1.1-windows -> D:\Projekte\PCONFSERV\pconfserv_poc_ui\node _modules\phantomjs-prebuilt\lib\phantom
[INFO] Writing location.js file                                                                                                                                                                       
[INFO] Done. Phantomjs binary available at D:\Projekte\PCONFSERV\pconfserv_poc_ui\node_modules\phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe

On my Jenkins Slave I´m getting:

[INFO] --- frontend-maven-plugin:1.8.0:npm (npm install phantomjs) @ pconfserv-poc-ui ---
[INFO] testFailureIgnore property is ignored in non test phases
[INFO] npm not inheriting proxy config from Maven
[INFO] Running 'npm install phantomjs-prebuilt --verbose' in /home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI
[INFO] npm info it worked if it ends with ok
[INFO] npm verb cli [ '/home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI/target/node/node',
[INFO] npm verb cli   '/home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI/target/node/node_modules/npm/bin/npm-cli.js',
[INFO] npm verb cli   'install',
[INFO] npm verb cli   'phantomjs-prebuilt',
[INFO] npm verb cli   '--verbose' ]
[INFO] npm info using npm@5.8.0
[INFO] npm info using node@v8.10.0
[INFO] npm verb npm-session 0baed854ac1edbdf
[INFO] npm verb type system
[INFO] npm verb stack FetchError: request to https://registry.npmjs.org/phantomjs-prebuilt failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
[INFO] npm verb stack     at ClientRequest.req.on.err (/home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI/target/node/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:68:14)
[INFO] npm verb stack     at emitOne (events.js:116:13)
[INFO] npm verb stack     at ClientRequest.emit (events.js:211:7)
[INFO] npm verb stack     at TLSSocket.socketErrorListener (_http_client.js:387:9)
[INFO] npm verb stack     at emitOne (events.js:116:13)
[INFO] npm verb stack     at TLSSocket.emit (events.js:211:7)
[INFO] npm verb stack     at emitErrorNT (internal/streams/destroy.js:64:8)
[INFO] npm verb stack     at _combinedTickCallback (internal/process/next_tick.js:138:11)
[INFO] npm verb stack     at process._tickCallback (internal/process/next_tick.js:180:9)
[INFO] npm verb cwd /home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI
[INFO] npm verb Linux 3.10.0-957.21.3.el7.x86_64
[INFO] npm verb argv "/home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI/target/node/node" "/home/jenkins/agent/workspace/pconfserv_poc_ui/_feature_OTDPKTPSTS-42-adjust-pconfserv-poc-ui/CI/target/node/node_modules/npm/bin/npm-cli.js" "install" "phantomjs-prebuilt" "--verbose"
[INFO] npm verb node v8.10.0
[INFO] npm verb npm  v5.8.0
[INFO] npm ERR! code ENOTFOUND
[INFO] npm ERR! errno ENOTFOUND
[INFO] npm ERR! network request to https://registry.npmjs.org/phantomjs-prebuilt failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
[INFO] npm ERR! network This is a problem related to network connectivity.
[INFO] npm ERR! network In most cases you are behind a proxy or have bad network settings.
[INFO] npm ERR! network 
[INFO] npm ERR! network If you are behind a proxy, please make sure that the
[INFO] npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
[INFO] npm verb exit [ 1, true ]
[INFO] 
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     /home/jenkins/.npm/_logs/2019-09-12T15_05_31_472Z-debug.log

Please mention your frontend-maven-plugin and operating system version. The frontend-maven-plugin is 1.8.0 (see above) The operating system is given as Linux 3.10.0-957.21.3.el7.x86_64 (running as a Docker Image in openShift)

toschder commented 5 years ago

I got a few steps forward and detected that for executing npm install phantomjs-prebuilt the right npm Proxy needs to be set 1st, in order to download that package. After downloading this, _phantomjscdnurl is reflected to download the remaining parts. I´ve changed the configuration now to:

...
<configuration>
            <arguments>install phantomjs-prebuilt --registry=https://lpnexus01.mycompany.net:8088/repository/mycompany_npm_repositories/ --strict-ssl=false --verbose</arguments>
</configuration>
...