6

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

我已经在 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在项目中也有文件,@craco文件夹中有node_modules文件夹。

然后当我尝试再次安装 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

Packages.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 新手。

4

4 回答 4

18

这对我有用

npm install @craco/craco --save
于 2021-04-16T09:04:17.983 回答
1

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

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

所以我们要做的是:

npm install @craco/craco

或者

npm install @craco/craco --save
于 2021-11-02T03:21:41.400 回答
0

首先,检查 package.json 文件中的 @craco/craco 版本

  npm install @craco/craco@5.8 --save
              OR 
  yarn add @craco/craco@5.8           

5.8 是 package.json 文件中 craco 的一个版本。

并关闭编辑器并重新打开尝试运行

于 2022-01-24T06:54:49.590 回答
0

确保craco你不能使用这个命令

npm install @craco/craco --legacy-peer-deps

确保craco.config.js是这样的

// craco.config.js
module.exports = {
    style: {
       postOptions: {
        plugins: [
          require('tailwindcss'),
          require('autoprefixer'),
        ],
      },
    },
  }
于 2022-01-17T17:53:14.560 回答