简体   繁体   English

create-react-app + npm start - 'react-scripts' 不被识别为内部或外部命令

[英]create-react-app + npm start - 'react-scripts' is not recognized as an internal or external command

Similar questions that I have tried following我试过的类似问题

"npm-run-all" is not recognized as an internal or external command “npm-run-all”未被识别为内部或外部命令

"'react-scripts' is not recognized as an internal or external command" “'react-scripts' 不被识别为内部或外部命令”

I am trying to create a React project via the create-react-app cli, but after creating the project I get the error我正在尝试通过 create-react-app cli 创建一个 React 项目,但在创建项目后出现错误

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

when I try to launch the dev server via npm start.当我尝试通过 npm start 启动开发服务器时。

What I have tried:我尝试过的:

1) Make sure Node and npm are installed and up to date. 1) 确保安装了 Node 和 npm 并且是最新的。 From the project directory I run (via powershell)从我运行的项目目录(通过 powershell)

> npm -v
6.7.0
> node -v
v11.11.0

2) Ensure that 'react-scripts' is listed with the correct version number in package.json 2)确保'react-scripts'在package.json中列出了正确的版本号

"name": "clipd2",
"version": "0.1.0",
"private": true,
"dependencies": {
    "react": "^16.8.4",
    "react-dom": "^16.8.4",
    "react-scripts": "^2.1.5"
 },
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }...

3) Delete node_modules folder and package-lock.json and reinstall npm packages 3) 删除 node_modules 文件夹和 package-lock.json 并重新安装 npm 包

rm -r -fo node_modules
rm package-lock.json
npm install
npm install -S react-scripts

After instalation the react-scripts directory is found (and populated) in node_modules安装后,在 node_modules 中找到(并填充)react-scripts 目录

4) Make sure npm is in the environment PATH variable 4) 确保 npm 在环境 PATH 变量中

> echo $Env:Path
....C:\Users\notMyUsername\AppData\Roaming\npm

I am at a loss for next steps.我对下一步感到茫然。 Strangely enough, I have another React app housed in the same parent directory奇怪的是,我在同一个父目录中有另一个 React 应用程序

clipdReact
    clipd
    clipd2

And there are no problems when using npm start in the clipd project (whereas the failing project is clipd2)并且在 clipd 项目中使用 npm start 时没有问题(而失败的项目是 clipd2)

Any suggestions or tips would be greatly appreciated!任何建议或提示将不胜感激!

**UPDATE **更新

This bug was filed but is still open react-scripts is not recognized此错误已提交但仍处于打开状态react-scripts 无法识别

You can start the dev server (from your project's directory) with您可以使用以下命令启动开发服务器(从您的项目目录中)

.\node_modules\.bin\react-scripts start

Be careful generating the production build with a command similar to the one above - I had problems with babel and polyfills when trying to do so.使用类似于上面的命令生成生产版本时要小心 - 我在尝试这样做时遇到了 babel 和 polyfills 的问题。

What worked for me in the end, was setting the script shell to powershell.最后对我有用的是将脚本外壳设置为 powershell。 The command for that is npm config set script-shell powershell and npm config delete script-shell to reset the config.该命令是npm config set script-shell powershellnpm config delete script-shell以重置配置。 I'm not sure why that worked, my guess is that since there are always 3 script files in node_modules\\.bin that somehow the wrong shell was used for the wrong script or something like that.我不确定为什么会这样,我的猜测是因为node_modules\\.bin中总是有 3 个脚本文件,不知何故,错误的 shell 被用于错误的脚本或类似的东西。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 create-react-app 上的“'npm' 未被识别为内部或外部命令” - "'npm' is not recognized as an internal or external command" on create-react-app 'react-scripts' 未被识别为内部或外部命令 - 'react-scripts' is not recognized as an internal or external command 'create-react-app' 未被识别为内部或外部命令 - 'create-react-app' is not recognized as an internal or external command 反应脚本:找不到命令(npm start) - react-scripts: command not found (npm start) react-scripts:在ubuntu的create-react-app项目上找不到? - react-scripts: not found on create-react-app project on ubuntu? 'react-scripts' 未被识别为内部或外部命令、可运行程序或批处理文件 - 2022 - 'react-scripts' is not recognized as an internal or external command, operable program or batch file - 2022 “create-react-app”不是内部或外部命令,也不是可运行的程序或批处理文件 - 'create-react-app' is not recognized as an internal or external command or operable program or batch file create-react-app 命令卡在使用 cra-template 安装 react react-dom react-scripts - create-react-app command stuck on installing react react-dom react-scripts with cra-template npm start throws sh: react-scripts: command not found - npm start throws sh: react-scripts: command not found create-react-app react-scripts start - ajv-errors:不支持:选项 jsonPointers。 可以使用已弃用的 jsPropertySyntax 代替 - create-react-app react-scripts start - ajv-errors: NOT SUPPORTED: option jsonPointers. Deprecated jsPropertySyntax can be used instead
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM