Require stack:
- /home/.../node_modules/react-app-rewired/bin/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/home/.../node_modules/react-app-rewired/bin/index.js:2:13)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/.../node_modules/react-app-rewired/bin/index.js'
]
}
For me we have a devDependency of @storybook/react@^5.3.19 which has a dependency of react-dev-utils@9.1.0. For some reason with this devDependency
NODE_ENV=production yarn install
put react-dev-utils innode_modules/react-scripts/node_modules/react-dev-utils
instead of in node_modules/react-dev-utils.If I uninstall @storybook/react (again, a devDependency…)
NODE_ENV=production yarn install ; yarn build
works fine.Simplest workaround is explicitly install react-dev-utils:
What is the solution of this issue?
I installed react-app-rewired and get following error:
my config override just returns the config as is for testing purposes now. So i have no error in config-override.js.
But what seems to be strange is the require stack. why is it pointing to the npm cache node_modules folder instead of the projects node_modules folder?
If anyone has a solution please let me know! Thanks!
Ok - something to try:
npm install
oryarn install
.Check for that directory again.
What should be happening, is the react-dev-utils package is supposed to be being hoisted into your main node_modules directory, since you don’t have any other versions that would be conflicting.
What I suspect may have happened is that you used to have something else that had a dependency on a different version of react-dev-utils. That other version was the one being hoisted, and as a part of migrating across that other dependency was removed. The second version of react-dev-utils under react-scripts was then not “moved up” out of the react-scripts node_modules directory automatically. If this is the case, deleting the node_modules directory and reinstalling should trigger installing the react-dev-utils version that react-scripts (and us!) rely on into the node_modules directory properly.
One other question: you say you are migrating over to react-app-rewired. Is this so that you can move back to create-react-app rather than as an ejected project? If so, great 😃. If not, react-app-rewired is designed specifically for use with a non-ejected app - once an app is ejected you already have full access to make the modifications by default that react-app-rewired enables for create-react-app, so it’s pretty pointless to migrate in that case.
Do you have react-scripts installed? React-dev-utils is a dependency of react-scripts, so it should be present if you have react-scripts installed. (It’s part of the create-react-app set of packages that are automatically installed when creating a react project).