title: How can I install npm by Maven in java
body: <p>I need to install npm by maven</p>
  <p>and I also use proxy.</p>
  <p>I add such build code in my pom.xml</p>
  <pre><code>    &lt;build&gt;
          &lt;finalName&gt;${project.artifactId}&lt;/finalName&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;com.github.eirslett&lt;/groupId&gt;
                  &lt;artifactId&gt;frontend-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.11.0&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;!-- optional: you don't really need execution ids, but it looks nice
                              in your build log. --&gt;
                          &lt;id&gt;install node and npm&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;install-node-and-npm&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;!-- optional: default phase is &quot;generate-resources&quot; --&gt;
                          &lt;phase&gt;generate-resources&lt;/phase&gt;
                          &lt;configuration&gt;
                              &lt;nodeVersion&gt;v0.10.33&lt;/nodeVersion&gt;
                              &lt;npmVersion&gt;1.3.10&lt;/npmVersion&gt;
                              &lt;!-- optional: where to download node and npm from. Defaults to http://nodejs.org/dist/ --&gt;
                              &lt;!-- &lt;downloadRoot&gt;http://myproxy.example.org/nodejs/dist/&lt;/downloadRoot&gt; --&gt;
                              &lt;!-- optional: where to install node and npm. Defaults to the working
                                  directory --&gt;
                              &lt;!-- &lt;installDirectory&gt;target&lt;/installDirectory&gt; --&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;npm install&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;npm&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;!-- optional: default phase is &quot;generate-resources&quot; --&gt;
                          &lt;phase&gt;generate-resources&lt;/phase&gt;
                          &lt;configuration&gt;
                              &lt;!-- optional: The default argument is actually &quot;install&quot;, so unless
                                  you need to run some other npm command, you can remove this whole &lt;configuration&gt;
                                  section. --&gt;
                              &lt;arguments&gt;install&lt;/arguments&gt;
                              &lt;noProxy&gt;true&lt;/noProxy&gt;
                              &lt;npmInheritsProxyConfigFromMaven&gt;false&lt;/npmInheritsProxyConfigFromMaven&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;set-npm-registry&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;npm&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;phase&gt;generate-resources&lt;/phase&gt;
                          &lt;configuration&gt;
                              &lt;arguments&gt;config set registry=&lt;/arguments&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;gulp build&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;gulp&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;!-- optional: the default phase is &quot;generate-resources&quot; --&gt;
                          &lt;phase&gt;generate-resources&lt;/phase&gt;
                          &lt;!-- &lt;configuration&gt; optional: if not specified, it will run gulp's
                              default task (and you can remove this whole &lt;configuration&gt; section.) &lt;arguments&gt;homepagejs_minify&lt;/arguments&gt;
                              &lt;/configuration&gt; --&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.12.4&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;skipTests&gt;true&lt;/skipTests&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;groupId&gt;com.kelveden&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-karma-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.3&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;skipTests&gt;true&lt;/skipTests&gt;
                  &lt;/configuration&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;unit-test&lt;/id&gt;
                          &lt;phase&gt;test&lt;/phase&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;start&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;configFile&gt;./src/test/resources/karma-e2e.conf.js&lt;/configFile&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  </code></pre>
  <p>and I also has such settings.xml</p>
  <p>where I config my proxy</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  
  &lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot;
            xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
            xsi:schemaLocation=&quot;http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd&quot;&gt;
   
      &lt;localRepository&gt;C:\Users\z1\.m2\repository&lt;/localRepository&gt;
  
      &lt;interactiveMode&gt;true&lt;/interactiveMode&gt;
  
      &lt;offline&gt;false&lt;/offline&gt;
  
      &lt;pluginGroups&gt;
  
      &lt;/pluginGroups&gt;
  
      &lt;proxies&gt;
  
          &lt;proxy&gt;
              &lt;id&gt;MyProxy&lt;/id&gt;
              &lt;active&gt;true&lt;/active&gt;
              &lt;protocol&gt;http&lt;/protocol&gt;
              &lt;host&gt;myProxyHost&lt;/host&gt;
              &lt;port&gt;8080&lt;/port&gt;
          &lt;/proxy&gt;
  
      &lt;/proxies&gt;
  
      &lt;servers&gt;
  
      &lt;/servers&gt;
  
      &lt;mirrors&gt;
  
      &lt;/mirrors&gt;
  
      &lt;profiles&gt;
  
      &lt;/profiles&gt;
  
  &lt;/settings&gt;
  
  </code></pre>
  <p>but npm cannot be installed by maven
  I got such error
  And as far as I understand windows blocks something
  my proxy cannot work</p>
  <pre><code>        [ERROR] npm ERR! System Windows_NT 6.2.9200
  
          [ERROR] npm ERR! command &quot;C:\\Users\\\abc\\\git1\\q2cngom-partner\\aoe_webapp\\node\\node.exe&quot; &quot;C:\\Users\\abc\\git1\\q2cngom-partner\\aoe_webapp\\node\\node_modules\\npm\\bin\\npm-cli.js&quot; &quot;install&quot; &quot;--color=false&quot; &quot;--proxy=http://myProxyHost:8080&quot;
  
          [ERROR] npm ERR! cwd C:\Users\abc\git1\\webapp
  
          [ERROR] npm ERR! node -v v0.10.33
  
          [ERROR] npm ERR! npm -v 1.3.10
  
          [ERROR] npm
  
          [INFO] ------------------------------------------------------------------------
  
          [INFO] BUILD FAILURE
  
          [INFO] ------------------------------------------------------------------------
  
          [INFO] Total time:  02:32 min
  
          [INFO] Finished at: 2021-02-04T21:05:56+05:30
  
          [INFO] ------------------------------------------------------------------------
  
          [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.26:npm (npm install) on project aoe_webapp: Failed to run task: 'npm install --color=false --proxy=http://myProxyHost:8080' failed. (error code 1) -&gt; [Help 1]
  
          org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:0.0.26:npm (npm install) on project aoe_webapp: Failed to run task
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
  
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
  
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
  
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
  
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
  
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
  
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
  
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
  
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
  
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
  
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
  
          at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
  
          at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
  
          at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
  
          at java.lang.reflect.Method.invoke (Method.java:498)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
  
          Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run task
  
          at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute (AbstractFrontendMojo.java:69)
  
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
  
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
  
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
  
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
  
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
  
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
  
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
  
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
  
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
  
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
  
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
  
          at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
  
          at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
  
          at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
  
          at java.lang.reflect.Method.invoke (Method.java:498)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
  
          Caused by: com.github.eirslett.maven.plugins.frontend.lib.TaskRunnerException: 'npm install --color=false --proxy=http://myProxyHost:8080' failed. (error code 1)
  
          at com.github.eirslett.maven.plugins.frontend.lib.NodeTaskExecutor.execute (NodeTaskExecutor.java:59)
  
          at com.github.eirslett.maven.plugins.frontend.mojo.NpmMojo.execute (NpmMojo.java:50)
  
          at com.github.eirslett.maven.plugins.frontend.mojo.AbstractFrontendMojo.execute (AbstractFrontendMojo.java:67)
  
          at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
  
          at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
  
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
  
          at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
  
          at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
  
          at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
  
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
  
          at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
  
          at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
  
          at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
  
          at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
  
          at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
  
          at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
  
          at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
  
          at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
  
          at java.lang.reflect.Method.invoke (Method.java:498)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
  
          at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
  
          [ERROR]
  
          [ERROR]
  
          [ERROR] For more information about the errors and possible solutions, please read the following articles:
  
          [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
  </code></pre>
  <p>How can I solve this problem?</p>
  <p>...................................
  ...................................
  ...................................
  ...................................</p>