我有一个父Maven项目,该项目本身包含了一个单独的前端项目。
当我使用cmd到前端文件夹并运行“ npm run build” 一切正常。
当我从父pom.xml运行“ mvn clean install -PautoInstallPackage” 时,父pom.xml会读取前端文件夹内的pom.xml并通过执行相同的命令 frontend-maven-plugin
“ npm run build” ,但这不起作用。
现在,如果在 npm run build --force
中在frontend-maven-plugin中添加参数然后整个Maven构建成功,但是没有文件被编译,它只是忽略了错误并继续进行。
以下是mvn全新安装的日志
[INFO] Running 'npm run build' in /Users/okaunds/Documents/Oliver/DTC/Repos/DTC-React-App/react-app
[INFO]
[INFO] > react-app@0.1.0 build /Users/okaunds/Documents/Oliver/DTC/Repos/DTC-React-App/react-app
[INFO] > npm-run-all pre-deploy deploy post-deploy
[INFO]
[INFO]
[INFO] > react-app@0.1.0 pre-deploy /Users/okaunds/Documents/Oliver/DTC/Repos/DTC-React-App/react-app
[INFO] > cp src/index.js src/index-backup.js && cp src/deploy.js src/index.js
[INFO]
[INFO]
[INFO] > react-app@0.1.0 deploy /Users/okaunds/Documents/Oliver/DTC/Repos/DTC-React-App/react-app
[INFO] > react-scripts build && clientlib --verbose
[INFO]
[INFO] Creating an optimized production build...
[INFO] Failed to compile.
[INFO]
[INFO] ./src/components/commons/header/header.scss
[INFO] Error: Missing binding /Users/okaunds/Documents/Oliver/DTC/Repos/DTC-React-App/react-app/node_modules/node-sass/vendor/darwin-x64-64/binding.node
[INFO] Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 10.x
[INFO]
[INFO] Found bindings for the following environments:
[INFO] - OS X 64-bit with Node.js 8.x
[INFO]
[INFO] This usually happens because your environment has changed since running `npm install`.
[INFO] Run `npm rebuild node-sass` to download the binding for your current environment.
[INFO]
[INFO]
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno 1
[ERROR] npm ERR! react-app@0.1.0 deploy: `react-scripts build && clientlib --verbose`
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the react-app@0.1.0 deploy script.
[ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:
[ERROR] npm ERR! /Users/okaunds/.npm/_logs/2019-06-20T10_09_39_830Z-debug.log
[ERROR] ERROR: "deploy" exited with 1.
[ERROR] npm ERR! code ELIFECYCLE
[ERROR] npm ERR! errno 1
[ERROR] npm ERR! react-app@0.1.0 build: `npm-run-all pre-deploy deploy post-deploy`
[ERROR] npm ERR! Exit status 1
[ERROR] npm ERR!
[ERROR] npm ERR! Failed at the react-app@0.1.0 build script.
[ERROR] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[ERROR]
[ERROR] npm ERR! A complete log of this run can be found in:
[ERROR] npm ERR! /Users/okaunds/.npm/_logs/2019-06-20T10_09_39_854Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Consumer Direct 0.0.1-SNAPSHOT ..................... SUCCESS [ 1.039 s]
[INFO] Consumer Direct - React App 0.0.1-SNAPSHOT ......... FAILURE [ 17.079 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.237 s
[INFO] Finished at: 2019-06-20T15:39:39+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.6:npm (npm run build) on project consumer-direct.react: Failed to run task: 'npm run build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :consumer-direct.react
答案 0 :(得分:0)
尝试将SASS添加到webpack.config.js
答案 1 :(得分:0)
确保所有的maven命令都使用相同的node
。 frontend-maven-plugin
在本地安装自己的node
和npm
。我遇到了一个问题,其中npm install
的maven任务使用本地安装的node
,但是npm run build
的任务使用的是我的计算机上全局安装的node
。
答案 2 :(得分:-1)
转到 ui.frontend 的 /pom.xml 并使用以下更新 node 和 npm 版本
<nodeVersion>${node.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>