当我尝试运行一个简单的程序时,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
我需要将React Codes Split与托管在 Firebase Hosting 上的 Create React App 结合使用。
但是,我有一个问题,因为Firebase Hosting 仅托管任何应用程序的最新版本。这意味着,如果您部署新的应用程序版本(N+1),并且用户打开现有版本(N),并且该用户跨越代码分割边界,他们将请求旧块(N),这不是不再在 Firebase 托管中托管,因为当前版本已更改 (N+1)。
那么,如何避免ChunkLoadErrorFirebase 托管中的代码拆分呢?有没有办法告诉 Firebase 托管保留您已部署的所有先前版本,并且仅添加最新版本中的新文件(例如index.htmlJS/CSS 块?)。
javascript reactjs google-cloud-platform firebase-hosting create-react-app
我正在使用 craco 创建一个反应应用程序。这是我的 ts 配置:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"downlevelIteration": true
},
"include": [
"src"
]
}
Run Code Online (Sandbox Code Playgroud)
我还使用 git 子模块从中导入 utils。
当我运行时craco start一切正常。但是当我运行时craco build我收到此错误:
Attempted import error: '@pinata/sdk' does not contain a default export (imported as 'pinataClient')
Run Code Online (Sandbox Code Playgroud)
这是pinataClient导入的方式:
import pinataClient "@pinata/sdk"; …Run Code Online (Sandbox Code Playgroud) 最近升级到了 React-scripts 版本 5.0.1,为此,我需要通过导入NodePolyfillPlugin我的 React-scripts 配置并将其添加到插件中来重新添加对 Node.js 核心模块的支持。这确实解决了我看到的错误,但现在我在尝试执行以下操作时遇到了一些新错误npm start:
Module not found: Error: You attempted to import /node_modules/console-browserify/index.js which falls outside of the project directory.
Run Code Online (Sandbox Code Playgroud)
对 console-browserify 的唯一引用来自 NodePolyfillPlugin。有谁知道为什么会发生这种情况以及我该如何解决它?
create-react-app ×10
reactjs ×8
craco ×3
javascript ×3
node.js ×3
typescript ×3
build ×1
css ×1
npm ×1
tailwind-css ×1
terminal ×1
three.js ×1
ts-nameof ×1
webpack ×1
windows ×1