score:441
to fix this issue simply upgrade react-scripts package (check latest version with npm info react-scripts version
):
- replace in your package.json
"react-scripts": "^3.x.x"
with"react-scripts": "^3.4.1"
(or the latest available version) - (optional for some) delete your node_modules folder
- run
npm install
oryarn install
some people reported that this issue was caused by running npm audit fix
(avoid it!).
score:0
follow the below steps. i also encountered the same problem.
- remove the whole node_modules folder.
- remove the package-lock.json file.
run command
npm install npm-install
as shown in the image:here we go.. npm start...wao
score:0
just need to remove and re-install react-scripts
to remove
yarn remove react-scripts
to add
yarn add react-scripts
and then rm -rf node_modules/ yarn.lock && yarn
- remember don't update the
react-scripts
version maually
score:0
i had the same issue running it in my pipeline.
for me, the issue was that i was using node
version v10.0.0
in my docker container.
updating it to v14.7.0
solved it for me
score:0
none of the other solutions worked for me.
however, adding this to my package.json fixed the issue for me:
"resolutions": {
"react-dev-utils": "10.0.0"
},
score:0
setting the home environment variable to an appropriate value fix this issue for me.
score:0
i fixed this issue by setting a newer version of node as default in nvm i.e.:
nvm alias default 12.xx.x
score:0
i was having the exact same issue for a gatsby blog. the dependencies couldn't be upgraded and could only run on npm version 10.22.1.
what works for me is the following:
#!/bin/bash
rm -rf .cache
rm -rf public
gatsby build
gatsby serve
basically the completely rebuild everything, and this error is gone. very annoying but at least it builds.
what's ever more weird is that, if i tweaked the image of the blog post, e.g., resizing it a bit, it builds. i have absolutely no idea why. but that least that's a clue.
score:0
if you have an ejected cra, there are a few changes to the webpack-dev-server config that if left unchanged will throw this error. comparing a freshly ejected cra 4.x config to my cra 3.x config showed a number of changes to functions that didn't previously accept arguments that now do.
in my case, one of the breaking changes was the addition of a path to their noopserviceworkermiddleware
function. adding in the missing path noopserviceworkermiddleware(paths.publicurl)
fixed this for me.
score:0
if you are finding it difficult to show up an image in you react.js file, i tried searching on youtube. it suggests adding image inside 'public' folder(rather than 'src' folder).
although still looking for reasons why adding images inside 'src' folder didnt worked out.
link:
https://www.youtube.com/watch?v=tamjct5oeoi&ab_channel=esterlingaccime
score:0
switching from powershell to bash fixed this problem for me.
score:0
this has nothing to do with react
, as the error specified, undefined is not accepted as the path argument. make sure you don't pass a variable to path.join that happens to be undefined or null.
for example:
const {path} = require('path');
let arg = undefined;
let mypath = path.join(__dirname, arg);
// the same error would occur.
score:1
if you have an ejected create-react-app
, i would suggest:
- create a new react app through
create-react-app
. - eject it through
npm run eject
oryarn eject
. - install all the packages that are missing from the
package.json
. - copy your src folder assuming all your code is situated in this folder.
- redo your changes on the config and script folders, if needed.
worked for me.
score:1
i tried various approach described above but none of them worked since i have ejected my css. finally applying following steps helped:
- upgrade
react-scripts
from"react-scripts": "3.x.x"
to"react-scripts": "^3.4.0"
- downgrading
react-dev-utils
form"react-dev-utils": "^10.x.x"
to"react-dev-utils": "10.0.0"
- delete
node-modules
folder andpackage-lock.json
/yarn.lock
- reinstall packages
npm install
/yarn install
score:1
in my case, it was because i (at one point) had reactn
installed, which also includes its own version of react (for some reason).
after that had been installed (even after uninstalling again), this error occured.
i simply removed node_modules
and ran npm install
again, and it worked.
score:1
i didn't want to upgrade react-scripts
, so i used the 3rd party reinstall npm module to reinstall it, and it worked.
npm i -g npm-reinstall
reinstall react-scripts
score:1
simply upgrading react-scripts
version solved my issue.
react-scripts
package from "react-scripts": "3.x.x"
to "react-scripts": "^3.4.1"
(or the latest available version).
avoid deleting package-lock.json
straightaway. first try this, if it doesn't work then proceed further.
score:2
if you ejected and are curious, this change on the cra repo is what is causing the error.
to fix it, you need to apply their changes; namely, the last set of files:
- packages/react-scripts/config/paths.js
- packages/react-scripts/config/webpack.config.js
- packages/react-scripts/config/webpackdevserver.config.js
- packages/react-scripts/package.json
- packages/react-scripts/scripts/build.js
- packages/react-scripts/scripts/start.js
personally, i think you should manually apply the changes because, unless you have been keeping up-to-date with all the changes, you could introduce another bug to your webpack bundle (because of a dependency mismatch or something).
or, you could do what geo angelopoulos suggested. it might take a while but at least your project would be in sync with the cra repo (and get all their latest enhancements!).
score:4
go to you package.json
change "react-scripts": "3.x.x" to "react-scripts": "^3.4.0" in the dependencies
reinstall react-scripts:
npm i react-scripts
start your project:
npm start
score:6
i had this same issue and running npm install react-scripts@latest
fixed my issue.
score:8
simply update react-scripts to the latest version.
yarn add react-scripts@latest
or if using npm
npm install react-scripts@latest
score:10
i just had this issue after installing and removing some npm packages and spent almost 5 hours to figure out what was going on.
what i did is basically copied my src/components in a different directory, then removed all the node modules and package-lock.json (if you are running your app in the docker container, remove images and rebuild it just to be safe); then reset it to my last commit and then put back my src/components then ran npm i
.
i hope it helps.
score:10
we ejected from react-scripts
and so could not simply upgrade the package.json entry to fix this.
instead, we did this:
- in a new directory, create a new project ->
$> npx create-react-app foo-project
- and then eject it ->
cd ./foo-project && npm run eject
- now copy the files from /foo-project/config into the config directory of our main app and fire up your dev server
hope this helps others in a similar bind.
score:18
running npm i react-dev-utils@10.0.0
solved my issue.
score:46
i've also faced this problem and figure out it by upgrading the react-scripts
package from "react-scripts": "3.x.x"
to "react-scripts": "^3.4.1"
(or the latest available version).
- delete
node_modules\
folder - delete
package-lock.json
file - rewrite the
package.json
file from"react-scripts": "3.x.x"
to"react-scripts": "^3.4.1"
- install node packages again
npm i
- now, start the project
npm start
and it works!!
score:63
if you have ejected, this is the proper way to fix this issue:
find this file config/webpackdevserver.config.js
and then inside this file find the following line:
app.use(noopserviceworkermiddleware());
you should change it to:
app.use(noopserviceworkermiddleware('/'));
for me(and probably most of you) the service worker is served at the root of the project. in case it's different for you, you can pass your base path instead.
Source: stackoverflow.com
Related Query
- TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined raised when starting react app
- TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
- The "path" argument must be of type string or an instance of Buffer or URL cloudinary and nodejs
- The \"path\" argument must be of type string or an instance of Buffer or URL. Received undefined from nodejs
- Trying to deploy my React app with gh-pages but got this error message : The "file" argument must be of type string. Received type undefined
- The "file" argument must be of type string. Received type undefined on npm run deploy to gh-pages
- The "path" argument must be of type string. Received undefined. not sure why?
- TypeError: The "original" argument must be of type Function
- Gatsby 3 "Path" argument must be of type string
- react-hot-loader: React.createElement: type is invalid -- expected a string error updating the screen
- Getting the following error when creating React HOC: type is invalid -- expected string or a class/function but got: object
- Adding url slug to Next Js routing getting TypeError path should be type string getting type object
- Error: Invalid value of type string for mapStateToProps argument when connecting component ConnectedForm
- How to fix the error argument of type string or undefined is not assignable to parameter of type string using typescript and react?
- Streamifier error - The "path" argument must be of type string. Received type function ([Function (anonymous)])
- compilation :First argument was an invalid path = "message-{Date.now()}" Paths must be non-empty strings and can't contain "."
- React.createElement: type is invalid -- expected a string
- A spread argument must either have a tuple type or be passed to a rest parameter React
- the title prop of a button must be a string - react native
- React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object
- Getting error "Path" argument must be string while deploying React - Loadable components sample code in cloud functions
- React How to fix Failed prop type - Invalid prop of type string expected object
- React: Invalid value for prop `savehere` on <div> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM
- React Native Element type is invalid expected a string but got undefined
- Argument of type 'string | null' is not assignable to parameter of type 'ValueFn<SVGPathElement, Datum[], string | number | boolean | null>'
- Why is React.Fragment causing the console error: Results Warning: React.createElement: type is invalid
- TypeScript saying a string is invalid even though it's in the union?
- gh-pages -d build gives Error "file" argument must be a non-empty string
- passing a type argument for the props of a react component for a higher order component
- The preloadedState argument passed to createStore has unexpected type of "Null". Expected argument to be an object with the following keys: "login"
More Query from same tag
- React setInterval in useEffect with setTimeout delay
- When I output the JavaScript map function to JSX, the value comes out strangely
- Firebase pagination with Mui-Datatable pagination and sorting
- Loading critical CSS in Next.js
- Issue with Varnish
- What does it mean to unravel a circular linked list?
- ReactJS : Fetch response not returning to componentDidMount; Failed to load PDF
- How to mock BrowserRouter of react-router-dom using jest
- tab key press ignore hidden area a & button elements
- 400 BAD REQUEST when POST using Axios in React
- React/TypeScript - Extending component with generic type and reuse generic type within component
- Routes component not updating on state change, console.log shows opposite of how component behaves
- How To Add My Own Svg Image Just Like Logo Is Shown By Default In Create-React-App
- Node.js (MERN) Serving static files and API's
- Is there a way to filter out nested null values within an api - reactjs
- Expressjs cors issue when fetching from different origin
- Import React Material UI Icons dynamically
- Proper way to render content without flickering ? React + Redux + TS
- JavaScript nested array filtering problem
- Removing an item causes React to remove the last DOM node instead of the one associated with that item
- How to get the value of the highlighted item with react-select-plus?
- Material UI - font size in button label
- How to transfer props in react v0.13?
- React Hook useMemo has missing dependencies
- Storybook JS Interaction Testing with Enzyme - State Changes being Overidden
- React Styled Components - How to access raw html
- How do I deal with d3.json to get my InitialState in React/redux
- Page content is not loading after redirect - React web app
- What actually happens when React component returns?
- How to design Redux stores and actions?