【问题标题】:React Cannot Start Project - 'craco' is not recognized as an internal or external commandReact 无法启动项目 - 'craco' 未被识别为内部或外部命令
【发布时间】:2021-06-23 12:31:43
【问题描述】:

谁能告诉我为什么我不能在开发服务器上启动我的网站项目?

我在 Windows 10 上克隆了一个文件,它曾经在我的 Mac OS 上运行良好......在它死之前:'(请随意尝试这个项目:https://github.com/EMDevelop/j2c

当我运行 npm start 时,我收到以下消息

> just2connect@0.1.0 start C:\Users\Ed\Desktop\Coding\React\j2c
> craco start

'craco' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! just2connect@0.1.0 start: `craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the just2connect@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_11_19_513Z-debug.log

这很奇怪,因为我有 "craco": "0.0.3" 作为依赖项,"start": "craco start" 作为我的 package.json 中的脚本。

我在项目中也有craco.config 文件,node_modules 文件夹中有@craco 文件夹。

当我再次尝试安装 craco (npm i @craco/craco) 并运行 npm start 时,我收到以下错误,要求我安装依赖项:

C:\Users\Ed\Desktop\Coding\React\j2c>npm i @craco/craco
npm WARN bootstrap@4.6.0 requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
npm WARN radium@0.25.2 requires a peer of react@^15.3.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-coverflow@0.2.20 requires a peer of react@^16.5.2 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@3.2.0 requires a peer of react-native-vector-icons@>7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@3.2.0 requires a peer of react-native-safe-area-context@^3.1.9 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-ratings@7.3.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-size-matters@0.3.1 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-only-when@1.0.2 requires a peer of react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-only-when@1.0.2 requires a peer of react-dom@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-particles-js@3.4.1 requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-swipeable@5.5.1 requires a peer of react@^16.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN react-testimonial@1.0.0 requires a peer of react@^16.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.20.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.

npm ERR! code EEXIST
npm ERR! path C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco
npm ERR! Refusing to delete C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco: is outside C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\@craco\craco and not a link
npm ERR! File exists: C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_29_51_457Z-debug.log

这也很奇怪,因为我在node_modules 文件夹(和package.json)中拥有大部分这些依赖项:

我担心只是鲁莽地强迫 craco 替换旧版本,然后我是否必须为它给我警告的每个依赖项都这样做?大多数依赖项已经存在。

然后,当我再次尝试运行 npm start 时,它给了我错误,就好像我再也没有安装过 craco:

C:\Users\Ed\Desktop\Coding\React\j2c>npm start

> just2connect@0.1.0 start C:\Users\Ed\Desktop\Coding\React\j2c
> craco start

'craco' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! just2connect@0.1.0 start: `craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the just2connect@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_30_25_218Z-debug.log

任何帮助将不胜感激!!拔掉我的头发,我是 Windows 新手。

【问题讨论】:

    标签: reactjs dependency-management npm-start craco


    【解决方案1】:

    这对我有用

    npm install @craco/craco --save
    

    【讨论】:

    • 我试过了,再次打开终端,仍然说'craco not found' ...
    【解决方案2】:

    这是 Tailwind css 特定于 React 应用程序的错误。

    由于 Create React App 不允许您在本地覆盖 PostCSS 配置,因此我们还需要安装 CRACO 才能配置 Tailwind。但不知何故 craco 没有安装在您的项目中。

    所以我们要做的就是:

    npm install @craco/craco
    

    npm install @craco/craco --save
    

    【讨论】:

      猜你喜欢
      • 2020-05-11
      • 2018-06-04
      • 2016-12-22
      • 1970-01-01
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      相关资源
      最近更新 更多