react-scripts: command not found

2020-06-09 04:14发布

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.

标签: reactjs
8条回答
戒情不戒烟
2楼-- · 2020-06-09 04:55

1.Delete node_modules, package-lock.json

command for deleting node_modules :

rm -rf node_modules

2.install react-scripts version 1.1.1

command for install react-scripts :

npm install react-scripts@1.1.1

3.npm install

4.now run server it will work fine.

Note : If you are a Linux user then don't forget to use sudo before npm

查看更多
【Aperson】
3楼-- · 2020-06-09 04:56

I use this in a dockerizer enviroment. I already install locally in node_modules using package.json.

so, I added this:

RUN npm install -g react-scripts
RUN npm install

That solved my confusing issue

查看更多
登录 后发表回答