Adding dependency gives error: 'react-scripts' is not recognized as an internal or external command, operable program or batch file"

余生颓废 提交于 2020-01-01 19:15:08

问题


Does anyone else get this issue? When i go to create a new project using create-react-app, and i add any dependency to it other than the stock ones, i.e. react-redux, redux, react-router-dom, i get the following error:

'react-scripts' is not recognized as an internal or external command, operable program or batch file.

I've tried building with different vs of the modules but that proved pointless.

Any advice on why would be amazing. The versions of the modules are the latest ones.


回答1:


You are getting that error because you node_modules are either not present their or they are not installed properly because when you are trying to start app with

something start

then it runs the start script from package.json so install the node_ modules properly to start the react app. Run npm install in the project directory where your package.json is




回答2:


@Aniruddh Agarwal and Strahinja Ajvaz gave me the hint.

I did start to use yarn for a while but for reason a package name couldn't be installed properly with yarn. I switched to npm install and it worked fine. After trying to run the code it failed. I did npm uninstall package and after that tried yarn add package again. It succeded this time (strange) and the application did start as before.



来源:https://stackoverflow.com/questions/46638007/adding-dependency-gives-error-react-scripts-is-not-recognized-as-an-internal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!