I'm getting 'Error: Cannot find module '../scripts/start' from projects set up using create-react-app that previously worked fine, now when i run 'npm start' i'm getting this error - the only workaround seems to be rm -rf node_modules followed by npm install, but next day I run into the same problem. Any ideas how to fix this please (see full error message below) - thanks.
>react-scripts start
module.js:549
throw err;
^
Error: Cannot find module '../scripts/start'
at Function.Module._resolveFilename (module.js:547:15)
at Function.resolve (internal/module.js:18:19)
at Object.<anonymous> (/Users/DANTHORY/Dropbox/card-slider-challenge_TESTING/node_modules/.bin/react-scripts:28:25)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
package.json:
{
"name":"card-slider-challenge",
"version":"0.1.0",
"private":true,
"scripts":{
"start":"react-scripts start",
"build":"react-scripts build",
"test":"jest",
"eject":"react-scripts eject",
"start-api":"json-server --port 3001 --watch --static none data/db.json"
},
"dependencies":{
"react":"^16.3.2",
"react-dom":"^16.3.2",
"react-slick":"^0.23.2"
},
"devDependencies":{
"jest":"^24.0.0",
"json-server":"^0.12.2",
"react-scripts":"^1.1.4"
}
}
Run the npm install react-scripts command to solve the "react-scripts: command not found" error. If necessary delete your node_modules directory and your package-lock. json file, reinstall your dependencies and restart your development server.
It's happening most likely because of an & in your folder name which is getting used as the path of your project. So Check the whole path trail of your project and rename any folder with "&" to only text-based names. The Run - npm start from the console. Hope it will solve your problem.
Both errors occurred because your NPM or Yarn program can’t find the react-scripts module, which should be installed in your node_modules folder. The react-scripts package is supposed to be installed when you create a new React application using Create React App command-line tool.
The react-scripts package is supposed to be installed when you create a new React application using Create React App command-line tool. To fix this kind of error, first check on your package.json file and see if react-scripts is listed as one of the dependencies in your project. Here’s what you should see in your package.json file:
That scripts/folder should have been added to source control, so that checking it out again would result in it still being there. You may need to use create-react-appagain to get that scripts/folder back
If your React application runs without any error, then copy your React project content (all the components and the dependencies) to this new React application and run your application from there.
I had the exact same issue and I did the following:
Delete node_modules folder
Run npm install
It fixed my issue, but what it caused, I don't know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With