I downloaded a React project from GitHub and tried to get it running on my local machine. First I installed the necessary packages:
npm install -g create-react-app
npm install --save react react-dom
Then I attempted to launch the development server:
npm start
However, this command fails with a ‘react-scripts: command not found’ error. The strange thing is that this same project works perfectly on the original computer where I developed it. But when I clone it to any other machine (tried on both Windows and Mac), I get this error. What could be causing this issue and how can I fix it?
you probably forgot to install react-scripts. just do npm install react-scripts --save and then try npm start again. it happens often when cloning. good luck!
You’re missing dependencies after cloning the repo. GitHub doesn’t include the node_modules folder when you clone, so you need to run npm install in the project directory first. This grabs all the dependencies from package.json, including react-scripts. Then npm start will work. Those commands you ran (npm install -g create-react-app and npm install --save react react-dom) are for creating new React apps or adding specific packages - they won’t install your project’s dependencies. Always run npm install right after cloning any Node.js project.
This happens when react-scripts is completely missing from your package.json file. Check your dependencies section - if react-scripts isn’t there, that’s why npm install won’t grab it. I hit this same issue when someone ejected their React app and manually deleted react-scripts from package.json. Fix it by adding react-scripts back to dependencies, or if you’ve ejected, use a different start command. Also check if you need a specific react-scripts version - newer ones sometimes break older React projects.