我最近向 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开发过程中投入所有内容,因为这对于我的团队来说非常烦人,因为在开发过程中必须一遍又一遍地更改该文件。
任何帮助表示赞赏。
我正在使用 TypeScript 开发一个 create-react-app,"include": "/src"每次运行该应用程序时,它都会在我的前端文件夹中自动生成一个 tsconfig,即使我删除了该文件或更改了它。
有没有办法禁用 TS cra 中的类型检查(不弹出)?
当我尝试运行一个简单的程序时,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) 我在停止渲染的页面上收到以下错误,在检查其他类似错误后,我仔细检查了导入是否正确并且安装了 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)
当我尝试在同一项目中使用@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附加信息
进行了bundle分析,得到以下结果:
// Used these …Run Code Online (Sandbox Code Playgroud) javascript three.js reactjs create-react-app react-three-fiber
我希望打字稿错误显示为警告,但不会导致我的开发服务器崩溃。我能够通过设置.env文件来为 eslint 做到这一点ESLINT_NO_DEV_ERRORS=true。
有等效的打字稿吗?
对于原型设计阶段来说,这确实会适得其反。
这个答案表明:
{
"compilerOptions": {
...
strict: false
}
)
Run Code Online (Sandbox Code Playgroud)
但这还配置了许多其他东西(即没有没有隐式任何)
谢谢!
基本上就是这个。我都尝试过
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) 我想在我的 React 应用程序中使用 Tailwind CSS。问题是CRACO start在默认端口(3000)上启动应用程序,我想要自定义端口,但我不知道什么是正确的方法。(在他们的文档中找不到任何有关此内容的信息)
我尝试了类似文件字段PORT=5000 CRACO start内的操作,但不起作用。任何想法?scriptspackage.json
我正在使用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
create-react-app ×10
reactjs ×8
typescript ×3
craco ×2
javascript ×2
node.js ×2
compilation ×1
css ×1
eslint ×1
npm ×1
prettier ×1
tailwind-css ×1
terminal ×1
three.js ×1
tiptap ×1
ts-nameof ×1
tsconfig ×1
windows ×1