My npm script in package.json looks like this:
"build": "$(npm bin)/react-scripts build",
OR
"build": "react-scripts build",
It throws the following error:
Error: Cannot find module '../scripts/build'
Require stack:
- /codebuild/output/src573716697/src/node_modules/.bin/react-scripts
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.resolve (internal/modules/cjs/helpers.js:80:19)
at Object.<anonymous> (/codebuild/output/src573716697/src/node_modules/.bin/react-scripts:31:23)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/codebuild/output/src573716697/src/node_modules/.bin/react-scripts'
]
}
If I change it to:
"build": "./node_modules/react-scripts/bin/react-scripts.js build",
It works, which basically means it is trying to find the scripts folder that is inside the react-scripts folder but not in the bin directory where the react-scripts executable is.
How do I fix this? I'd like to use the executables from my package.json instead and do not like to have to give the entire path to the js script.