[frontend-maven-plugin]-Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6.0:npm

frontend-maven-plugin问题

    • 问题描述
    • mvn clean package -e

使用frontend-maven-plugin插件打包web程序(vue或react等)时,出现报错

问题描述

  • 打包相关pom写法
            
                com.github.eirslett
                frontend-maven-plugin
                12.8.3
                
                    target
                    src/main/direct-debit/
                
                
                    
                        install node and npm
                        
                            install-node-and-npm
                        
                        
                            ${node.version}
                            ${npm.version}
                            https://npm.taobao.org/mirrors/node/
                            http://registry.npmjs.org/npm/-/
                            
                        
                    
                    
                        npm install
                        
                            npm
                        
                        
                            install
                            https://registry.npm.taobao.org/
                        
                    
                    
                        npm build
                        
                            npm
                        
                        
                            run build
                        
                    
                
            
  • 点击maven install
    [frontend-maven-plugin]-Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6.0:npm_第1张图片
  • 错误信息
[ERROR]Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6.0:npm (npm install) on project project-web: Failed to run task: 'npm install --registry=https://registry.npm.taobao.org/' failed. java.io.IOException: Cannot run program "D:\project-web\project-web-web\target\node\node.exe" (in directory "D:\project-web\project-web-web\src\main\fr-web"): 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.

根据报错信息发现,是说node不是有效的程序,在本地打开对应的node所在文件夹点击该程序发现存在版本不对,无法运行该程序

mvn clean package -e

如果需要查看更具体的错误信息,可以执行 mvn clean package -e 查看,会执行打包并显示更详细的错误信息

  • 错误信息
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.9.0:npm (npm install) on project project-web-web: Failed to run task: 'npm install --registry=https://registry.npm.taobao.org/' failed. java.io.IOException: Cannot run program
"D:\project-web\project-web-web\target\node\node.exe" (in directory "D:\project-web\project-web-web\src\main\fr-web"): CreateProcess error=193, %1 不是有效的 Win32 应用程
序。 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.9.0:npm (npm install) on project project-web-web: Failed to run task

CreateProcess error=193, %1 不是有效的 Win32 应用程序。

你可以在本地执行以上命令,打开生成的target所在目录,点击其中node.exe程序,发现无法执行,下载的node.exe版本,不是window所对应的可执行程序,因此出现该问题

然后尝试发现在12.3.1能够下载正常可执行版本,12.18.3版本无法下载对应所需正常版本,14.9.0也可以下载对应版本,因此分析可能是12.8.3版本有问题,跳过非正常版本

你可能感兴趣的:(前端模块开发)