无法创建React App

时间:2017-08-03 12:27:38

标签: javascript node.js reactjs path create-react-app

我有以下项目:

我有一个源文件夹src,其结构如下

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

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

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

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”来启动react开发服务器时,我遇到了以下问题:

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

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

有人可以帮我解决路径吗? (我猜对了问题是路径,还是其他东西?)

1 个答案:

答案 0 :(得分:0)

您必须向.babelrc添加反应:

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