create-react-app: Error when running npm start with react-scripts 3.3.1 after updating dependencies
Describe the bug
Latest version of react-dev-utils breaks compatibility with old react-scripts.
Did you try recovering your dependencies?
yes
Which terms did you search for in User Guide?
n/a
Steps to reproduce
npx create-react-app bug-test
then npm install react-scripts@3.3.1
then npm start
.
Expected behavior
Runs webpack-dev-server and watches and compiles files.
Actual behavior
Throws an exception when accessing the page.
The latest version of react-scripts invokes noopServiceWorkerMiddleware with a path, while the previous version did not. This breaks the watch command since the middleware is now joining on undefined, throwing an exception.
This is because react-scripts@3.3.1 pulls in react-dev-utils@10.2.0 since it is versioned with a caret.
TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received type undefined at validateString (internal/validators.js:125:11) at Object.join (path.js:1147:7) at noopServiceWorkerMiddleware (/Users/*/projects/bug-test/node_modules/react-dev-utils/noopServiceWorkerMiddleware.js:14:26)
Reproducible demo
Can make one if needed.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 24
- Comments: 15 (1 by maintainers)
Links to this issue
Commits related to this issue
- fix: see https://github.com/facebook/create-react-app/issues/8490\#issuecomment-586556584 — committed to himenoyusa/setu-project by deleted user 4 years ago
- updated react-scripts to fix bug https://github.com/facebook/create-react-app/issues/8490 — committed to cse442-at-ub/cse442-semester-project-blood-donaters by deleted user 4 years ago
- Fix error when running client app The error: ``` TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. "Received type undefined" ``` The fix: Upgrade react-scripts to 3.4.0 ... — committed to sabrina-s/furryfriendfinder by sabrina-s 4 years ago
- Upgrade react-scripts to 3.4.0 Summary: Loading dagit would cause the following error: ``` The "path" argument must be of type string. Received undefined ``` This was an issue in `react-scripts`. U... — committed to dagster-io/dagster by helloworld 4 years ago
- Updated react-scripts to 3.4.0 This is because of a breaking dependency in react-dev-utils@10.2.0 Context: https://github.com/facebook/create-react-app/issues/8490 — committed to auth0-samples/auth0-react-samples by deleted user 4 years ago
- fix: dev bug that can't start app https://github.com/facebook/create-react-app/issues/8490 — committed to wisebr/react-formgen by wisebr 4 years ago
Yes upgrading to 3.4.0 fixes it, as does pinning react-dev-utils to previous version. However all projects running react-scripts 3.3.* without dependencies lock (or after npm update) will be broken unless react-dev-utils is fixed to handle the undefined argument. It isn’t a hassle for me, really appreciate all the good work in CRA, just helping those that encounter the error.
Thanks for digging into this @voxtex . I was losing my mind all afternoon trying to figure out what I had changed that broke my app.
"react-scripts": "^3.4.0"
fixes this issue for me as well.Closing as it was fixed in
3.4.0
. Thanks for the patience folks!If you aren’t able to upgrade
react-scripts
for any reason, you can force a working resolution forreact-dev-utils
: package.jsonI saw the same today as well, seems to be fixed on 3.4.0.
Looks maybe related to projects that have completely removed the service worker file.
Reproduced here: https://github.com/zgriesinger/cra-error-example
@jamesplease you’re a god sent, thank you!