我想设置我的VS代码来调试使用'create-react-app'创建的React-app.
我试过这个配置:
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch node",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/src/index.js",
"cwd": "${workspaceRoot}",
"preLaunchTask": null,
"runtimeExecutable": null,
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": []
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 9222,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
Run Code Online (Sandbox Code Playgroud)
但我得到错误以下错误:
Debugger listening on port 11198
e:\form\src\index.js:1
(function (exports, require, module, __filename, __dirname) { import React from 'react';
^^^^^^
SyntaxError: Unexpected …Run Code Online (Sandbox Code Playgroud) debugging visual-studio-code create-react-app vscode-settings
我create-react-app用来构建应用程序,当我运行npm run build时,它会在内部创建带有静态文件夹的build文件夹。
build-> static
但是,当我在build文件夹中看到index.html文件时,资产的路径/static不是/build/static,这就是为什么页面缺少资产导致无法正确加载的原因。
我可以做些配置设置来解决此问题吗?
编译失败./src/index.js模块构建失败:错误:使用
babel-preset-react-app要求您指定NODE_ENV或BABEL_ENV环境变量.有效值为"development","test"和"production".相反,收到:"未定义".(在处理预设:"C:\ Users\mitch\OneDrive\Development\Git\react-seed \node_modules\babel-preset-react-app\index.js")处于Array.map(本机)
我不断得到上面的错误,无论我尝试设置环境或环境变量有多少奇怪和奇妙的方法,因为更新我的react-app后我甚至得到了一个由'create-react-app'创建的新应用程序脚本 - 我明显做错了什么?
我将在我的项目中使用Semantic-UI-React,但我遇到了以下问题:
文档链接:https://react.semantic-ui.com/usage#css
文档说支持webpack 1但不推荐.我正在使用随Webpack版本1.14.0一起提供的Create React App.这是否意味着我不应该使用Semantic-UI-ReactCRA?
对于样式,我也想在我的项目中使用一些自定义样式,所以我选择Semantic UI了文档中提到的第三个包选项..
npm install semantic-ui --save-dev在gulp内部运行并创建一个semantic文件夹.但是dist文档中没有提到文件夹.我应该semantic.min.css在index.js文件中引用哪条路径?
我基本上是试图利用Semantic-UI-React与semantic.min.css一些我自己的在它之上的风格.但似乎我在设置中犯了一些错误.另一个选择可能是继续Semantic UI CSS包裹?...但根据文档,我将无法使用此方法使用自定义样式.
我在这里有点困惑,请帮忙:)
reactjs semantic-ui redux create-react-app semantic-ui-react
在本地测试时,我的create-react-quiz应用程序完美运行.我基于这段代码完成了我的项目:https://github.com/mitchgavan/react-multi-choice-quiz/tree/gh-pages.
但是,当我在"GitHub-Pages"分支上使用npm build deploy时,会出现一个空白页面,并且这些错误会显示在控制台中:pk8189.github.io/: 1 GET pk8189.github.io/pk8189/futureU- /static/css/main.1dc4d41f.css pk8189.github.io/:1获取pk8189.github.io/pk8189/futureU-/static/js/main.28e294a0.js
这是我的回购:https://github.com/pk8189/futureU- 您认为这个问题是什么?感谢您的任何帮助.
我有一组pdf文件位于我项目的文件夹中.
我需要做的就是创建一个指向这些PDF文件的链接,并在浏览器中查看或下载它们.
我使用React Router 4和React 16以及create-react-app bootstrapping工具.
无论我如何链接它(链接组件或标签)它仍然在我的路由器配置中的最后一个路由.
谷歌最近两个小时一直在谷歌...但没有运气..
有没有办法告诉路由器不要路由PDF/XLS文件?
谢谢
我正在使用"react-router-dom": "^4.2.2"。
如果我测试,localhost:3000/second它会完美运行。
当我使用nginx在ubuntu服务器上上传此文件并尝试时www.website.com,它可以工作。当我尝试使用www.website.com/second它时,它给了我404 not found。我正在使用create-react-app。
app.js
class TestRoutes extends React.Component{
constructor(props){
super(props);
}
render(){
return(<React.Fragment>
<BrowserRouter>
<Switch>
<Route exact path='/' component={MainPage}/>
<Route path='/second' component={SecondPage}/>
<Route path='/third' component={ThirdPage}/>
</Switch>
</BrowserRouter>
</React.Fragment>);
}
}
ReactDOM.render(<TestRoutes/>, document.getElementById("root"));
Run Code Online (Sandbox Code Playgroud)
/ etc / nginx / sites-available / default 这是服务器上的配置文件
server {
listen 443 ssl;
root /var/www/reactcamera/build;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name website.com …Run Code Online (Sandbox Code Playgroud) 我有一个回购,在两个单独的文件夹中具有后端和前端(create-react-app)。对于build命令,我有类似的东西cd frontend && npm run build,对于publish目录,我有类似的东西frontend/build,但这不起作用。
我使用创建了一个React应用程序,create-react-app并选择不弹出。目前,我正在尝试使用导入本地字体@font-face,但没有成功。
这是我当前的文件夹结构:
/
+ public/
+ src/
-- index.js
-- App.js
-- App.css
++ assets/
+++ css/
---- general.css
+++ fonts/
---- CircularStd-Medium.woff
Run Code Online (Sandbox Code Playgroud)
在上App.js,我正在导入general.css文件(import './assets/css/general.css';)。
在general.css档案上,我按@font-face如下所述进行设置:
@font-face {
font-family: 'CircularStd-Medium';
font-style: normal;
src: local('CircularStd-Medium'), local('CircularStd-Medium'),
url('../fonts/CircularStd-Medium.woff') format('woff'),
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试遵循此答案,但是没有用。该代码可以编译,但是会显示一个简单的Times New Roman。
我下载了安装程序node-v10.6.0-x64和create-react-app-master软件包以用于React Application。在PhpStorm上创建React App项目之后,我遇到了如下异常:
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module 'react-dev-utils/crossSpawn'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (D:\Projects\ReactProjects\create-react-app-master\packages\react-scripts\bin\react-scripts.js:18:15)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `cd packages/react-scripts && node bin/react-scripts.js start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably …Run Code Online (Sandbox Code Playgroud) create-react-app ×10
reactjs ×8
node.js ×2
redux ×2
babel ×1
css ×1
debugging ×1
ecmascript-6 ×1
fonts ×1
github-pages ×1
javascript ×1
netlify ×1
nginx ×1
phpstorm ×1
react-router ×1
semantic-ui ×1
static-site ×1
web ×1