frontend-maven-plugin icon indicating copy to clipboard operation
frontend-maven-plugin copied to clipboard

[Question] How to using npm proxy config from .npmrc

Open hoangdt9 opened this issue 3 years ago • 1 comments
trafficstars

Hello guys,

I'm working on Maven and npm with different proxy for both. I would like to disable Maven proxy and using npm proxy from (.npmrc). I tried setup in pom.xml followed as https://github.com/eirslett/frontend-maven-plugin#proxy-settings but when download npm it's always refer Maven proxy ([INFO] Downloading via proxy http{protocol='http', host='70.10.15.10', port=8080, nonProxyHosts='localhost|70.*|nexus.sdsdev.co.kr'}).

Thank you!

  • Maven proxy: (settings.xml) http true http 70.10.15.10 8080 <nonProxyHosts>localhost|70.*|nexus.sdsdev.co.kr</nonProxyHosts>

  • npm proxy: (.npmrc) strict-ssl=false proxy=http://182.192.254.44:8080/ https-proxy=http://182.192.254.44:8080/ registry=https://registry.npmjs.org/ sass_binary_site=http://182.192.254.44:8080/repository/github/sass/node-sass/releases/download noproxy=nexus.sdsdev.co.kr,http://70.121.224.52:8081

  • pom.xml <groupId>com.github.eirslett</groupId> <artifactId>frontend-maven-plugin</artifactId> 1.12.1

              <configuration>
                  <workingDirectory>src/frontend</workingDirectory>
                  <!--Disable Maven Proxy-->
                  <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
              </configuration>
    
           <executions>
    
                  <execution>
                      <id>Install node and npm</id>
                      ....
    
                      <configuration>
                          <npmDownloadRoot>
                              <!--what link should place here?-->
                          </npmDownloadRoot>
                     </configuration>
                  </execution>
    
                   <execution>
                      <id>npm install</id>
                      ...
                      <configuration>
                          <npmInheritsProxyConfigFromMaven>false</npmInheritsProxyConfigFromMaven>
                          <arguments>install --proxy=http://182.192.254.44:8080/
                              --noproxy=nexus.sdsdev.co.kr,http://70.121.224.52:8081
                              --registry=https://registry.npmjs.org/
                          </arguments>
                      </configuration>
                  </execution>
    
      </executions>
    

hoangdt9 avatar Jan 11 '22 07:01 hoangdt9

Another way to set a registry is to add a .npmrc file in your project's root directory https://github.com/eirslett/frontend-maven-plugin#readme It doesn't respect the one in your home directory, you need to copy it to your project

zymzxq avatar Jul 01 '22 04:07 zymzxq