// react-scripts/scripts/start.js
//L15
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
throw err;
});
when you're missing a dependency you get an error and a crash
/node_modules/react-scripts/scripts/start.js:19
throw err;
^
[Error: ENOENT: no such file or directory, stat '/initrd.img'] {
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/initrd.img'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
when you remove process.on('unhandledRejection', err => { throw err; }); it gives you a much more useful error and doesn't crash
Failed to compile.
./node_modules/[redacted]/dist/index.modern.js
Module not found: Can't resolve 'framer-motion' in '/home/[redacted]/node_modules/[redacted]/dist'
that small addition of code makes things much harder to debug when simply missing a peer dependency or something similar and could stop people dead in their tracks. maybe it should be removed until a better way of handling it can be thought of?
Since node v15, the --unhandled-rejections default is throw (source) so it seems this process.on('unhandledRejection', err => { is redundant; Node would throw nowadays (LTS is v16 currently).
when you're missing a dependency you get an error and a crash
when you remove
process.on('unhandledRejection', err => { throw err; });
it gives you a much more useful error and doesn't crashthat small addition of code makes things much harder to debug when simply missing a peer dependency or something similar and could stop people dead in their tracks. maybe it should be removed until a better way of handling it can be thought of?