标签: react-scripts

如何在 Visual Studio 代码中调试“create-react-app”?

我尝试了这里和其他地方提出的建议,但无法让 vscode 调试器正常工作,IE 断点永远不会激活,当然它们也不会中断。

应用程序通常通过npm startwhich调用来运行react-scripts start

我已经尝试过这些启动配置:

  {
    "version": "0.2.0",
    "configurations": [
      {
        "name": "Launch Chrome against localhost",
        "type": "pwa-chrome",
        "request": "launch",
        "url": "http://localhost:3000",
        "webRoot": "${workspaceFolder}"
      },
      {
        // I adapted this from a config to debug tests
        "name": "create-react-app",
        "type": "node",
        "request": "launch",
        "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
        "args": ["start"],
        "cwd": "${workspaceRoot}",
        "protocol": "inspector",
        "console": "integratedTerminal"
      }
    ]
  }
Run Code Online (Sandbox Code Playgroud)

node.js reactjs visual-studio-code react-scripts create-react-app

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

如何在create-react-app中将`src`文件夹更改为其他内容

我想知道是否可以使用react-script重命名srcapp文件夹等其他内容

reactjs react-scripts create-react-app

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

如何从react-scripts构建脚本获取详细日志?

我升级到react-scriptsv5,但构建失败并显示一条无用的消息:

Creating an optimized production build...
Failed to compile.

Module not found: Error: Can't resolve '...' in '/project/src'
Run Code Online (Sandbox Code Playgroud)

src正如您所看到的,它仅告诉我目录(实际上是整个项目)存在问题。

如何增加该脚本的详细程度?

reactjs react-scripts

19
推荐指数
1
解决办法
4167
查看次数

构建后index.html中的相对路径

您好我有一个reactjs应用程序,我用bellow命令构建我的项目

npm build
Run Code Online (Sandbox Code Playgroud)

这是我的package.json档案:

  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"},
Run Code Online (Sandbox Code Playgroud)

在构建之后我有包含构建文件和index.html文件的文件夹但是这个.html中的所有路径都是绝对的,我想用相对路径构建

例如(index.html):现在我有:

<script type="text/javascript" src="/static/js/main.af2bdfd5.js"></script>
<link href="/static/css/main.097da2df.css" rel="stylesheet">
<link rel="shortcut icon" href="/favicon.ico">
Run Code Online (Sandbox Code Playgroud)

我要这个:

<script type="text/javascript" src="./static/js/main.af2bdfd5.js"></script>
<link href="./static/css/main.097da2df.css" rel="stylesheet">
<link rel="shortcut icon" href="./favicon.ico">
Run Code Online (Sandbox Code Playgroud)

build path npm reactjs react-scripts

17
推荐指数
4
解决办法
2万
查看次数

如何配置react-script以便它不会覆盖'start'上的tsconfig.json

我目前正在使用create-react-app我的一个项目来引导它.基本上,我试图在tsconfig.json中设置路径,方法是将它们添加到create-react-app生成的默认tsconfig.json中:

"baseUrl": "./src",
"paths": {
  "interfaces/*": [
    "common/interfaces/*",
  ],
  "components/*": [
    "common/components/*",
  ],
},
Run Code Online (Sandbox Code Playgroud)

但是,每次运行yarn start基本上都运行时react-scripts start,它会删除我的更改并再次生成默认配置.

如何告诉create-react-app使用我的自定义配置?

typescript reactjs react-scripts create-react-app

16
推荐指数
3
解决办法
5002
查看次数

ReactJS 测试 - fsevents 不是函数

我正在尝试为我的程序编写测试用例,我听到了关于testing-library/react和 的好消息jest-junit。我使用 npm 将两个软件包安装到我的devDependencies并更改了我的测试脚本:"test": 'react-scripts test"当我运行 npm test 时,我得到错误提示

TypeError: fsevents is not a function

所以我尝试 npm i fsevents 但它没有帮助。我尝试在网上查找,但错误是 fsevents 不是构造函数或更改为纱线。

是什么导致了这个问题?我正在使用 npm v6.4.1 和 react-script v3.1.1

编辑:如果重要的话,也使用 Mac

Edi2:我再次运行测试,没有任何更改就不再出现此错误。

unit-testing typeerror npm reactjs react-scripts

13
推荐指数
4
解决办法
8562
查看次数

生产/构建中的 Material-UI 渲染错误

我在构建我的 react-app 时遇到了大问题。

我在正常的 react-scripts start dev-server 上使用 material-ui/core v.4.10.2 一切正常。

但是当通过 Nginx 或 npm-module serve 构建和提供服务时,渲染无法正常工作......

(我在material-ui Github上看到了类似的问题,但是都被(错误地)关闭了


这是我的 package.json 以防我的依赖项有问题(我当然不认为是这种情况)

{
  "name": "web_app",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.10.2",
    "@material-ui/styles": "4.10.0",
    "@material-ui/icons": "^4.2.1",
    "@material-ui/lab": "^4.0.0-alpha.45",
    "rc-color-picker": "^1.2.6",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "react-infinite-scroll-hook": "^2.0.1",
    "react-router-dom": "^5.0.1",
    "react-scripts": "3.1.1",
    "tinycolor2": "^1.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not …
Run Code Online (Sandbox Code Playgroud)

node.js reactjs material-ui react-scripts

13
推荐指数
2
解决办法
4092
查看次数

在React应用程序中运行npm start时出现babel-jest依赖问题

我正在做的就是运行create-react-app和cd'ing到应用程序,然后尝试运行npm/yarn start.我得到以下错误/输出/日志.我已经完成了所有建议的步骤.唯一有效的是我的.env中的SKIP_PREFLIGHT_CHECK = true作为Yarn和npm的最后手段.我最近更新到Mojave,如果人们有类似的经历,我不得不重新安装我的Xcode.

如果图像不够,我粘贴下面的输出.

非常感谢你提前帮助...杰森

控制台截图 截图

Last login: Tue Oct 30 16:30:24 on ttys002
TheLAB11:~ jasonspiller$ cd repos/react-express-graphql-app/
TheLAB11:react-express-graphql-app jasonspiller$ npm start

> react-express-graphql-app@0.1.0 start /Users/jasonspiller/repos/react-express-graphql-app
> react-scripts start


There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

  "babel-jest": "23.6.0"

Don't try to install it manually: your package …
Run Code Online (Sandbox Code Playgroud)

macos npm reactjs react-scripts yarnpkg

12
推荐指数
7
解决办法
7545
查看次数

postcss 7.0.0 - 8.2.9 严重性:中度正则表达式拒绝服务

在 下创建新项目时create-react-app,您会立即收到有关postcss.

npm 报告的问题:https ://www.npmjs.com/advisories/1693

相关的未决问题可以在这里找到:

该问题已在 上修补postcss v8.2.10,但在创建新项目时仍然存在,因为react-scripts尚未升级依赖项。

所以,我的问题是我无法再运行构建,因为它们由于漏洞而失败。

由于我迫不及待地等待他们修补它以继续处理我的东西(他们似乎从一年前就意识到了这一点),是否有一些解决方法可以用来解决它?

我尝试添加一个postcss分辨率package.json

  "resolutions": {
    "postcss": "^8.2.10"
  },
Run Code Online (Sandbox Code Playgroud)

但这并没有让我失望。

任何的想法?

reactjs postcss react-scripts create-react-app

12
推荐指数
1
解决办法
6889
查看次数

如何在没有 create-react-app 的情况下手动配置 React 的最小设置?

我不想使用create-react-app. 那么如何为一个简单的 React 应用程序配置一个最小的工作开发环境呢?

注意:我知道我可能只是在运行时将所有内容都包含为 JS(这是有据可查的),但我不想要这个,因为我仍然想要一个可用于生产的版本!

想要的:

  • 进行任何缩小(请参阅此处的相关问题
  • 进行任何连接(或者,如果更容易做到,我可能会将所有 JS 连接到一个文件中)
  • 任何比我编写的 JS 更旧的浏览器支持(所以没有这样做的转译)
  • 任何开发服务器(我可以手动重新加载。)
  • 任何实时重新加载或高级开发功能

我确实想:

  • 使用 React 组件
  • (可选)包括 JSX(我知道可以在没有它的情况下使用 React,但假设这是我想从 React 中获得的最小优势。但是,请告诉我,设置/配置的哪些额外步骤会“花费”包括,所以这个答案适用于那些想要 JSX 的人和那些不想要的人。)

基本上,只想使用 React。没有它周围的所有花哨的其他东西!*

我只是问这个,因为官方 React 文档没有提到这种可能性。


注意:为那些想知道为什么我想要这个的人推理。

* 实际上,忽略这些方便的开发功能等听起来太疯狂了。但我声称这有正当的理由/用例。我的意思是,所有这些对我来说都是不可用的/破坏了东西,因为我正在尝试使用 React 构建浏览器扩展


是的,我看到了这个非常相似的问题,但不幸的是,用户比我领先一步,答案只是针对他们问题的非常具体的答案。我想先了解一般情况,即我需要什么以及如何设置

node.js npm reactjs react-scripts create-react-app

11
推荐指数
1
解决办法
4244
查看次数