我尝试了这里和其他地方提出的建议,但无法让 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
我想知道是否可以使用react-script重命名src为app文件夹等其他内容
我升级到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应用程序,我用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):现在我有:
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)<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">
我目前正在使用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使用我的自定义配置?
我正在尝试为我的程序编写测试用例,我听到了关于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:我再次运行测试,没有任何更改就不再出现此错误。
我在正常的 react-scripts start dev-server 上使用 material-ui/core v.4.10.2 一切正常。
但是当通过 Nginx 或 npm-module serve 构建和提供服务时,渲染无法正常工作......
(我在material-ui Github上看到了类似的问题,但是都被(错误地)关闭了
{
"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) 我正在做的就是运行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) 在 下创建新项目时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)
但这并没有让我失望。
任何的想法?
我不想使用create-react-app. 那么如何为一个简单的 React 应用程序配置一个最小的工作开发环境呢?
注意:我知道我可能只是在运行时将所有内容都包含为 JS(这是有据可查的),但我不想要这个,因为我仍然想要一个可用于生产的版本!
我不想要的:
我确实想:
基本上,我只想使用 React。没有它周围的所有花哨的其他东西!*
我只是问这个,因为官方 React 文档没有提到这种可能性。
注意:为那些想知道为什么我想要这个的人推理。
* 实际上,忽略这些方便的开发功能等听起来太疯狂了。但我声称这有正当的理由/用例。我的意思是,所有这些对我来说都是不可用的/破坏了东西,因为我正在尝试使用 React 构建浏览器扩展。
是的,我看到了这个非常相似的问题,但不幸的是,用户比我领先一步,答案只是针对他们问题的非常具体的答案。我想先了解一般情况,即我需要什么以及如何设置?
react-scripts ×10
reactjs ×10
npm ×4
node.js ×3
build ×1
macos ×1
material-ui ×1
path ×1
postcss ×1
typeerror ×1
typescript ×1
unit-testing ×1
yarnpkg ×1