简体   繁体   English

为什么我不能在 ec2 上构建 create-react-app?

[英]Why can I not build create-react-app on ec2?

I've been playing with create-react-app for a little bit now on my local machine.我一直在我的本地机器上玩create-react-app一段时间。 I also create a basic express app that I'm running on my ec2 instance and so I wanted to push my create-react-app based project onto the ec2 and serve the build.我还创建了一个在我的ec2实例上运行的基本express应用程序,因此我想将基于create-react-app的项目推送到ec2并为构建提供服务。 The two commands of interest are npm run start and npm run build .感兴趣的两个命令是npm run startnpm run build

Unfortunately when running npm start (i believe 'run' isn't necessary for the command actually) on the ec2, I get a ton of errors.不幸的是,在 ec2 上运行npm start (我认为实际上命令不需要“运行”)时,我收到了很多错误。

[ec2-user@ip-172-31-62-133 ab-site-2017-summer]$ npm start

> ab-site@0.1.0 start /home/ec2-user/ab-site-2017-summer
> react-scripts start

/home/ec2-user/ab-site-2017-summer/node_modules/react-scripts/scripts/start.js:33
const {
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ab-site@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the ab-site@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ec2-user/.npm/_logs/2017-06-26T03_51_22_790Z-debug.log

note : that I did notice some problems when npm install 'ing the node_modules for this project on the ec2 .注意:在ec2上为这个项目npm install node_modules时,我确实注意到了一些问题。 I'm also not 100% (as a non-web-dev) whether my fundamental approach here is correct.我也不是 100%(作为非网络开发人员)我在这里的基本方法是否正确。 My goal is to build the dist asset with npm build and than point my express app to serve the index.html file for my domain's index route.我的目标是使用npm build dist资产,然后指向我的express应用程序为我的域的索引路由提供index.html文件。 My front-end, through react-router should handle all the UI and front-end routing from there.我的前端,通过react-router应该从那里处理所有 UI 和前端路由。

Per the create-react-app README , you'll need to have Node >= 6 installed on your EC2 instance in order to build and run the app (the poster is using Node 4.4.5).根据create-react-app README ,您需要在 EC2 实例上安装 Node >= 6 才能构建和运行应用程序(海报使用的是 Node 4.4.5)。

The error you are seeing is that Node 4 doesn't know how to handle ES6 destructuring syntax, which wasn't introduced until Node 6.4.0 (see http://node.green ).您看到的错误是 Node 4 不知道如何处理 ES6 解构语法,该语法直到 Node 6.4.0 才引入(请参阅http://node.green )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM