简体   繁体   English

使用babel为生产服务器设置节点应用程序

[英]setting up node application for production server using babel

I'm trying to get my first ever node app ready for a production server. 我正在尝试为生产服务器准备好我的第一个节点应用程序。

build and serve scripts I'm basing on that given by babel 我基于babel给出的内容来构建和提供脚本

"scripts": {
    "start": "nodemon --exec babel-node server.js --ignore public/",
    "build": "babel server.js -o server_compiled.js",
    "serve": "node server_compiled.js",
    "dev": "webpack -wd"

} }

npm run build

works as expected 按预期工作

npm run serve

results in an error: 导致错误:

some/path/config.js:3

export default{
^^^^^^
SyntaxError: Unexpected token export

This is from a config file that I'm referencing in server.js for port host and db. 这来自我在server.js中为端口主机和数据库引用的配置文件。

Do I build this file also or what have I done wrong? 我是否还要生成此文件,或者我做错了什么?

Any help appreciated. 任何帮助表示赞赏。

So, I eventually figured out I had to compile all of the .js files in the app individually. 因此,我最终发现我必须分别编译应用程序中的所有.js文件。 I'm sure there must be automated way to do this but thought I'd leave the solution in case anyone can't find anything else. 我确定必须有一种自动化的方法来完成此操作,但是我认为如果有人找不到其他东西,我会离开解决方案。

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

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