Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

Tags:

reactjs

I am trying to run a react application in my local machine , I get this error when I ran npm run start:

> node scripts/start.js

internal/validators.js:125
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

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.resolve (path.js:161:7)
    at resolveApp (D:\Projects\react-app\react-site-master\config\paths.js:10:41)
    at Object.<anonymous> (D:\Projects\react-app\react-site-master\config\paths.js:73:13)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node scripts/start.js`
npm ERR! Exit status 1

I have tried to do the following but it is the same:

  1. npm cache clean --force
  2. delete node_modules with package-lock.json
  3. npm install

Thanks in advance,

like image 654
L. Dabbeet Avatar asked Oct 02 '19 09:10

L. Dabbeet


2 Answers

Make sure you have the correct version of react-scripts. Try react-scripts 3.4.0.

If you have a previous version of react-scripts, you can follow the directions on how to migrate from your version to 3.4.0: https://github.com/facebook/create-react-app/releases

Another option is to update your package.json file to use "react-scripts": "3.4.0". Make sure you delete your node_modules folder and package-lock.json before running npm install after updating the package.json

like image 99
Kendra Loves Code Avatar answered Nov 02 '22 03:11

Kendra Loves Code


Changing my version of react-scripts from 3.3.1 to 3.4.0 worked for me. Use the command

npm install --save --save-exact [email protected]

If you have [email protected] already you can upgrade it to v3.4.1 with the same command. This automatically updates the version listed on your package.json file.

like image 1
deiza Avatar answered Nov 02 '22 03:11

deiza