无法创建React App [英] Cannot create React App

查看:144
本文介绍了无法创建React App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下项目:

我有一个具有以下结构的源文件夹src

I have a source folder src with the following structure

src/
├── sass/
│   └── sass files
│
├── js/
│   ├── admin
│   │    └── React project (an Admin Dashboard)
│   │
│   └── main
│        └── Javascript for the main site
│
└── pug/
    └── pug files

我使用create-react-app创建了react项目,然后我不得不将其弹出,以便将其移动到想要的结构中.

I used create-react-app to create the react project, and then I had to eject it so I could move it into my structure where I wanted.

我这样写出了弹出的config/paths.js中的路径:

I wrote over the paths in the ejected config/paths.js like this:

module.exports = {
  dotenv: resolveApp('.env'),
  appBuild: resolveApp('docs'),
  appPublic: resolveApp('src/public'),
  appHtml: resolveApp('src/public/index.html'),
  appIndexJs: resolveApp('src/js/admin/index.js'),
  appPackageJson: resolveApp('package.json'),
  appSrc: resolveApp('src'),
  yarnLockFile: resolveApp('yarn.lock'),
  testsSetup: resolveApp('src/setupTests.js'),
  appNodeModules: resolveApp('./node_modules'),
  publicUrl: getPublicUrl(resolveApp('package.json')),
  servedPath: getServedPath(resolveApp('package.json')),
};

但是当我运行命令"node scripts/start.js"以启动反应开发服务器时,出现以下问题:

But when I run the command "node scripts/start.js" to start the react development server I get the following problem:

Starting development server....
Failed to compile.
Syntax error: Unexpected token (19:16)

  17 | 
  18 | 
> 19 | ReactDOM.render(<App />, document.getElementById('root'));
     |                 ^
  20 | registerServiceWorker();

有人可以帮我解决这些问题吗? (我猜对了,问题出在路径上,还是可能是其他原因?)

Could someone help me resolve the paths? (Am I guessing right that the problem is with the paths, or it can be something else?)

推荐答案

您必须添加对.babelrc的反应:

-{ "presets": ["es2015"] }
+{ "presets": ["es2015", "react"] }

这篇关于无法创建React App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆