我有以下项目:
我有一个具有以下结构的源文件夹 src
src/
├── sass/
│ └── sass files
│
├── js/
│ ├── admin
│ │ └── React project (an Admin Dashboard)
│ │
│ └── main
│ └── Javascript for the main site
│
└── pug/
└── pug files
我使用 create-react-app 来创建 react 项目,然后我必须弹出它,以便我可以将其移动到我想要的结构中。
我在弹出的配置/路径中写了路径.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"来启动反应开发服务器时,我遇到了以下问题:
Starting development server....
Failed to compile.
Syntax error: Unexpected token (19:16)
17 |
18 |
> 19 | ReactDOM.render(<App />, document.getElementById('root'));
| ^
20 | registerServiceWorker();
有人可以帮我解决路径吗?(我猜对了,问题出在路径上,还是其他原因?
你必须添加对.babelrc
的反应:
-{ "presets": ["es2015"] }
+{ "presets": ["es2015", "react"] }