0

I have parent Maven project which engulfs a separate frontend project within itself.

When I go using cmd to the frontend folder and run "npm run build" everything works fine.

When I run "mvn clean install -PautoInstallPackage" from my parent pom.xml, the parent pom.xml reads the pom.xml inside the frontend folder and executes the same command via frontend-maven-plugin

"npm run build" but this doesn't work.

Now if I add an argument in frontend-maven-plugin as npm run build --force

then the overall maven build succeeds but no files are compiled, it just ignores the error and proceeds ahead.

Below is the log for mvn clean install

[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
Oliver
  • 6,152
  • 2
  • 42
  • 75

4 Answers4

0

Try to add SASS to webpack.config.js

Remigiusz
  • 19
  • 2
0

Make sure all the maven commands use the same node. frontend-maven-plugin installs its own node and npm locally. I had this issue where maven task for npm install used the locally installed node, but task for npm run build was using node globally installed on my machine.

Adam Libuša
  • 685
  • 7
  • 24
0

When running the react-scripts build on the CI, the build script treats warnings as errors because by default process.env.CI = true.

In your package.json, update build as below to override process.env.CI value to false

"scripts": {
    "start": "react-scripts start",
    "build": "CI=false && react-scripts build",  // Add CI=False here
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
-1

Go to /pom.xml of ui.frontend and update node and npm versions with below

<nodeVersion>${node.version}</nodeVersion>
<npmVersion>${npm.version}</npmVersion>
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Please explain why you think this solves the problem as it stands it doesn't explain anything. – Narrim Apr 19 '21 at 02:00