标签: create-react-app

允许 create-react-app 编译时出现 ESLint 错误

我最近向 create-react-app 添加了 ESLint 和 prettier 以及一系列配置。

以下是软件包:

"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.1.2",
Run Code Online (Sandbox Code Playgroud)

现在的问题是开发服务器无法编译,因为项目中存在大量 ESLint 错误。它说:

Failed to compile

*list of errors*

This error occurred during the build time and cannot be dismissed.
Run Code Online (Sandbox Code Playgroud)

这是高度侵入性的。我需要它仍然能够编译,因为我没有看到它因为某些样式问题而拒绝这样做的原因。

如果不进行一些修改(例如将所有 ESLint 错误设置为警告级别),如何防止这种情况发生。我也不想弹出。

我也希望不要在.eslintigore开发过程中投入所有内容,因为这对于我的团队来说非常烦人,因为在开发过程中必须一遍又一遍地更改该文件。

任何帮助表示赞赏。

compilation reactjs eslint create-react-app prettier

6
推荐指数
1
解决办法
2481
查看次数

create-react-app --template typescript — 是否可以暂时禁用类型检查?

我正在使用 TypeScript 开发一个 create-react-app,"include": "/src"每次运行该应用程序时,它都会在我的前端文件夹中自动生成一个 tsconfig,即使我删除了该文件或更改了它。

有没有办法禁用 TS cra 中的类型检查(不弹出)?

typescript tsconfig create-react-app

6
推荐指数
1
解决办法
4377
查看次数

尝试运行命令 npx create react app 时创建 React App 出错:spawn UNKNOWN

当我尝试运行一个简单的程序时,npx create-react-app我收到此错误:

D:\>npx create-react-app abc
npx: installed 67 in 4.255s

Creating a new React app in D:\abc.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


Aborting installation.
Unexpected error. Please report it as a bug:
Error: spawn UNKNOWN
    at ChildProcess.spawn (internal/child_process.js:403:11)
    at Object.spawn (child_process.js:553:9)
    at spawn (C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\node_modules\cross-spawn\index.js:12:24)
    at C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\createReactApp.js:407:19
    at new Promise (<anonymous>)
    at install (C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\createReactApp.js:359:10)
    at C:\Users\Gilang\AppData\Roaming\npm-cache\_npx\17768\node_modules\create-react-app\createReactApp.js:485:16
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  errno: -4094,
  code: 'UNKNOWN',
  syscall: 'spawn'
}

Deleting …
Run Code Online (Sandbox Code Playgroud)

javascript windows node.js reactjs create-react-app

6
推荐指数
1
解决办法
1万
查看次数

无法找到文件:“index.js”与磁盘上的相应名称不匹配:“.\node_modules\React\react”错误,React 导入正确

我在停止渲染的页面上收到以下错误,在检查其他类似错误后,我仔细检查了导入是否正确并且安装了 node_modules 反应索引文件。

还有什么可能导致这种情况?昨天我突然遇到了 linting 问题,我以为已经解决了。

它引用的文件应该是node_modules/React/react.indexjs,但在我的系统上是node_modules/react.index.js。我自己没有改变过,所以我不确定它来自哪里。我还删除了添加到此文件中可能导致此问题的任何代码。

Cannot find file: 'index.js' does not match the corresponding name on disk: '.\node_modules\React\react'
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在此输入图像描述

reactjs create-react-app

6
推荐指数
1
解决办法
2万
查看次数

警告:正在导入 Three.js 的多个实例

当我尝试在同一项目中使用@react-three/fiber和时,我收到以下警告。@react-three/drei

在此输入图像描述

重现步骤

npx create-react-app reproduced-warning
cd reproduced-warning
npm install three @react-three/fiber @react-three/drei
Run Code Online (Sandbox Code Playgroud)

我的src/App.js文件如下所示:

import React from 'react';
import { Canvas } from '@react-three/fiber';
import { Stats } from '@react-three/drei';

import './App.css';

const App = (props) => {
  return (
    <div className="App">
      <Canvas />
    </div>
  );  
};

export default App;
Run Code Online (Sandbox Code Playgroud)

要启动应用程序运行npm run start。

模块信息

  • three在^0.128.0
  • @react-three/fiber在^6.0.16
  • @react-three/drei在^4.2.0

更新(2021 年 5 月 4 日)

附加信息

进行了bundle分析,得到以下结果:

// Used these …
Run Code Online (Sandbox Code Playgroud)

javascript three.js reactjs create-react-app react-three-fiber

6
推荐指数
1
解决办法
6859
查看次数

创建反应应用程序无法编译打字稿错误

我希望打字稿错误显示为警告,但不会导致我的开发服务器崩溃。我能够通过设置.env文件来为 eslint 做到这一点ESLINT_NO_DEV_ERRORS=true。

有等效的打字稿吗?

对于原型设计阶段来说,这确实会适得其反。

这个答案表明:

{
  "compilerOptions": {
    ...
    strict: false
  }
)
Run Code Online (Sandbox Code Playgroud)

但这还配置了许多其他东西(即没有没有隐式任何)

谢谢!

typescript create-react-app

6
推荐指数
1
解决办法
3449
查看次数

如何将 ts-nameof 与 create-react-app 或 craco 一起使用?

我想在我的 React 应用程序中使用ts-nameofcreate-react-app使用. 我怎样才能做到这一点而不弹出?提示:我也使用craco,所以涉及 craco 的解决方案对我来说也很好。

谢谢!

typescript reactjs create-react-app craco ts-nameof

6
推荐指数
1
解决办法
393
查看次数

由于与 babel 的依赖关系,安装 React 时出现问题

基本上就是这个。我都尝试过

npm init react-app my-app
Run Code Online (Sandbox Code Playgroud)

和

npx create-react-app my-app
Run Code Online (Sandbox Code Playgroud)

我总是收到这样的消息:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @babel/core@7.12.3
npm ERR! node_modules/@babel/core
npm ERR!   @babel/core@"7.12.3" from react-scripts@4.0.3
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"*" from the root project
npm ERR!   @babel/core@"^7.12.3" from @svgr/webpack@5.5.0
npm ERR!   node_modules/@svgr/webpack
npm ERR!     @svgr/webpack@"5.5.0" from react-scripts@4.0.3
npm ERR!     node_modules/react-scripts
npm ERR!       react-scripts@"*" from the root project
npm ERR!   9 more (babel-jest, babel-loader, ...)
npm ERR!
npm ERR! …
Run Code Online (Sandbox Code Playgroud)

terminal node.js npm reactjs create-react-app

6
推荐指数
1
解决办法
3715
查看次数

如何使用 CRACO 在自定义端口上启动 React 应用程序?

我想在我的 React 应用程序中使用 Tailwind CSS。问题是CRACO start在默认端口(3000)上启动应用程序,我想要自定义端口,但我不知道什么是正确的方法。(在他们的文档中找不到任何有关此内容的信息)

我尝试了类似文件字段PORT=5000 CRACO start内的操作,但不起作用。任何想法?scriptspackage.json

css reactjs create-react-app tailwind-css craco

6
推荐指数
2
解决办法
1万
查看次数

提示Tap useEditor 返回 null

我正在使用useEditorTipTap 库中的函数来创建编辑器,但它首先返回 null。我的意思是,如果我使用useEditor并立即记录我设置的变量,它会返回 null,但随后会返回一个 Editor 对象。我正在使用 React 和 create-react-app。

我的 App.js 文件中有这个:

const editorUse = useEditor({
    extensions: [StarterKit],
    content: JSON.parse(localStorage.getItem("text")) ?? "",
  });
  console.log(editorUse);
Run Code Online (Sandbox Code Playgroud)

它打印出这个: 错误图像

代码沙箱:https://codesandbox.io/s/zealous-darwin-iswww?file =/src/App.js

reactjs create-react-app tiptap

6
推荐指数
1
解决办法
2143
查看次数