【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:

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

 

緩存自己的後,再次運行pom.xml就可以了。
 

補充:frontend-maven-plugin插件的作用自行百度,概況就是本地機器無需安裝node環境,也能自行打包程序。它自己會去下載node輕簡版。

我還特意把我本地的node在環境變量的配置去掉(專門測試這個插件,減少本地node干擾),發現果然能正常打包,這也證明這個插件確實能自行下載node去運行pom.xml,而不去依賴本地環境。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章