timarney / react-app-rewired

Override create-react-app webpack configs without ejecting
MIT License
9.81k stars 425 forks source link

react-app-rewired build does not terminate on error #493

Closed marcolilli closed 2 years ago

marcolilli commented 4 years ago

Environment

name version
node 12.16.1
npm 6.14.8
react-app-rewired 2.1.6

Issue

When run react-app-rewired build on a project with a missing dependency (is required in code but does not exist in package.json) the script shows an error but does not exit. This is a problem since it leads to never ending build pipelines in my CI/CD.

Steps to reproduce

  1. Require a missing dependency in code to be build
  2. run react-app-rewired build

Expected: Script exits on error Actually: Script displays error but keeps running

Console output

Failed to compile.

./src/components/Component.tsx
Cannot find module: 'package-name'. Make sure this package is installed.

You can install this package by running: npm install package-name.

[Expected to exit here]
pelhu commented 3 years ago

Any solution for this issue ?

dawnmist commented 3 years ago

I am not able to duplicate this and suspect that there is a combination of libraries in use that is contributing to the problem, as with essentially a clean create-react-app project with react-app-rewired added it does not occur - at least, not on my OS/machine.

Example repository used: https://github.com/dawnmist/react-app-rewired-test-520

Steps taken:

Result: Every run exited once the run failed due to the missing web-vitals package.

Tested with both nodejs versions 10.23.3 and 12.20.2 in case it was a version issue with nodejs, running on Debian 10 'Buster' version of linux.

username@host (master *)> ./node_modules/.bin/react-app-rewired build
Creating an optimized production build...
Failed to compile.

./src/reportWebVitals.tsx
Cannot find module: 'web-vitals'. Make sure this package is installed.

You can install this package by running: yarn add web-vitals.

PWD: ~/src/react-app-rewired-test-520
username@host (master *)> yarn build
yarn run v1.22.5
$ react-app-rewired build
Creating an optimized production build...
Failed to compile.

./src/reportWebVitals.tsx
Cannot find module: 'web-vitals'. Make sure this package is installed.

You can install this package by running: yarn add web-vitals.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PWD: ~/src/react-app-rewired-test-520
username@host (master *)> npm run-script build

> react-app-rewired-test-520@0.1.0 build /home/username/src/react-app-rewired-test-520
> react-app-rewired build

Creating an optimized production build...
Failed to compile.

./src/reportWebVitals.tsx
Cannot find module: 'web-vitals'. Make sure this package is installed.

You can install this package by running: yarn add web-vitals.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-app-rewired-test-520@0.1.0 build: `react-app-rewired build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the react-app-rewired-test-520@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/username/.npm/_logs/datetime-debug.log

I will need more information on what is going on to be able to take this any further, particularly OS (and shell used if Windows) and if possible an example repository that reproduces/demonstrates the problem.

I'd also ask if someone who is experiencing the issue please test this on the example repository I posted above using the same set of steps listed above on their machine to see if my example repository demonstrates the issue on their machine as well, to narrow down whether it is something specific to the project that experiences this verses occurring on all projects on that machine.

marcolilli commented 3 years ago

@dawnmist Thank you for you effort. I'll test the repository you provided in our infrastructure and let you know if I have any news.