【bug解决】Failed to execute goal...frontend-maven-plugin:1.0:npm....Cannot run program...node.exe...

【bug记录】

环境:win10 64位电脑。node版本v6.2.0(内置npm版本3.8.9)

完整bug报错:

D:\common\jdk1.8.0_91\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\workspace-idea\xxxx -Dmaven.home=D:\common\apache-maven-3.6.1 -Dclassworlds.conf=D:\common\apache-maven-3.6.1\bin\m2.conf "-javaagent:D:\common\IntelliJ IDEA 2018.2.6\lib\idea_rt.jar=63810:D:\common\IntelliJ IDEA 2018.2.6\bin" -Dfile.encoding=UTF-8 -classpath D:\common\apache-maven-3.6.1\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version=2018.2.6 -DskipTests=true package
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.fulong.pid:xxxx >-----------------------
[INFO] Building xxxx Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- frontend-maven-plugin:1.0:install-node-and-npm (install node and npm) @ xxxx ---
[INFO] Installing node version v6.2.0
[INFO] Copying node binary from D:\common\maven_resposity\com\github\eirslett\node\6.2.0\node-6.2.0-windows-x64.exe to D:\workspace-idea\xxxx\src\main\webapp\node\node.exe
[INFO] Installed node locally.
[INFO] Installing npm version 3.8.9
[INFO] Unpacking D:\common\maven_resposity\com\github\eirslett\npm\3.8.9\npm-3.8.9.tar.gz into D:\workspace-idea\xxxx\src\main\webapp\node\node_modules
[INFO] Installed npm locally.
[INFO] 
[INFO] --- frontend-maven-plugin:1.0:npm (npm cache clean) @ xxxx ---
[INFO] Running 'npm cache clean --registry=https://scm.fulongtech.cn/nexus/content/groups/npm/' in D:\workspace-idea\xxxx\src\main\webapp
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.183 s
[INFO] Finished at: 2020-05-13T09:50:58+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm cache clean) on project xxxx: Failed to run task: 'npm cache clean --registry=https://scm.fulongtech.cn/nexus/content/groups/npm/' failed. java.io.IOException: Cannot run program "D:\workspace-idea\xxxx\src\main\webapp\node\node.exe" (in directory "D:\workspace-idea\xxxx\src\main\webapp"): CreateProcess error=193, %1 不是有效的 Win32 应用程序。 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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

Process finished with exit code 1

解决关键性代码:

[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0:npm (npm cache clean) on project xxxx: Failed to run task: 'npm cache clean --registry=https://scm.fulongtech.cn/nexus/content/groups/npm/' failed. java.io.IOException: Cannot run program "D:\workspace-idea\xxxx\src\main\webapp\node\node.exe" (in directory "D:\workspace-idea\xxxx\src\main\webapp"): CreateProcess error=193, %1 不是有效的 Win32 应用程序。 -> [Help 1]

我个人笨拙的翻译:如图位置的node.exe(这个node显然不是我本地那个)无法loading  这个插件:frontend-maven-plugin

由于pom里配置它下载的node版本和我本地是一致的。所以我就把它下载的删了,将我本地的node直接复制过去就解决了。

下面是原来那破插件自己下载的node:

【bug解决】Failed to execute goal...frontend-maven-plugin:1.0:npm....Cannot run program...node.exe..._第1张图片

下面是我自己的node,红色框框是相同部分。

【bug解决】Failed to execute goal...frontend-maven-plugin:1.0:npm....Cannot run program...node.exe..._第2张图片

 

缓存自己的后,再次运行pom.xml就可以了。
 

补充:frontend-maven-plugin插件的作用自行百度,概况就是本地机器无需安装node环境,也能自行打包程序。它自己会去下载node轻简版。

我还特意把我本地的node在环境变量的配置去掉(专门测试这个插件,减少本地node干扰),发现果然能正常打包,这也证明这个插件确实能自行下载node去运行pom.xml,而不去依赖本地环境。

 

你可能感兴趣的:(nodejs)