I am currently trying to use create-react-app which uses three different packages: react, react-scripts and react-dom. I have installed create-react-app and then when I change into the directory and hit npm start
I get a react-scripts: command not found
. I've ran into a lot of problems with this. I can see react-scripts
is in my node_modules
folder but I keep getting command not found
when trying to run npm start
. I tried to delete and re-install all of my node_modules
but it didn't work. Anyone else having this issue?
✘ ✝ Node/toDoApp/my-test master± npm start
> my-test@0.1.0 start /Users/jzilch/Desktop/Web
Projects/Node:Express/Node/toDoApp/my-test
> react-scripts start
sh: react-scripts: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-test@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-test@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
I fixed it by changing folder name in my local system, from
to
However, the git branch name remains like "new/landing". This was the case with my MAC system.
i too faced this problem once .to solve this ,delete your
it works .
Firstly Delete
package-lock.json
file in your project folder.And then install dependencies again by
npm install
. That should solve this issue.As I was using
yarn
, I had to runyarn add react-scripts
.This usually happens because of a bad npm packages installation (using npm and yarn at the same time?). It can be desperating, but if you try these steps, it should work.
1st solution:
Remove
node_modules
folder. At the project's root folder, run2nd solution:
At the project's root folder, run
Next time you want to add a dependency using create-react-app, I recommend you to use 'yarn add' instead of 'npm install'. (Source: https://github.com/facebook/create-react-app/issues/1155)
I had this problem for ages and I eventually found my solution by sheer chance.
Turns out, you can't have spaces in any folder names.
e.g.
~/projects/tutorial/ReactJS/JavaScript Framework: ReactJS/app-name
won't work becauseJavaScript Framework: ReactJS
contains spaces.In general, it's probably not great practice to be using spaces in folder/file names anyway but I hope this saves someone at least 4 hours of trial and error.
I would recommend removing the
:
from your folder names too! (just to be safe)