简体   繁体   English

在节点服务器上提供Vue.js服务器端渲染

[英]Serving Vue.js Server Side Rendering on Node-server

I'm trying to get the Hackernews 2.0 demo up and running on my Digital Ocean droplet, but I fail. 我试图在我的Digital Ocean Droplet上启动并运行Hackernews 2.0演示,但失败了。

  • npm run start spins up the server on :8080. npm run start在:8080上npm run start服务器。
  • npm run build builds for production. npm run build版本进行生产。

The defined build tasks are defined here: 定义的构建任务在此处定义:

  "scripts": {
    "dev": "node server",
    "start": "cross-env NODE_ENV=production node server",
    "build": "npm run build:client && npm run build:server",
    "build:client": "cross-env NODE_ENV=production webpack --config build/webpack.client.config.js --progress --hide-modules",
    "build:server": "cross-env NODE_ENV=production webpack --config build/webpack.server.config.js --progress --hide-modules"
  }

...and the entire repo is here . ... 整个仓库都在这里

But what should I execute to serve as a :80 website? 但是,我应该执行什么才能充当:80网站?

I asked on Gitter.im, on the Vue-channel, but with zero success. 我在Vue频道上的Gitter.im上询问,但成功率为零。

Anyone? 任何人?

You don't need to execute anything special. 您无需执行任何特殊操作。 Simply change the definiton of listen port inside the application, on line 89 of server.js 只需在server.js的第89行更改应用程序内的侦听端口的定义

const port = process.env.PORT || 80   // << changed here

or export env Var PORT prior to start. 或在启动前导出env Var PORT。 In linux, something like 在linux中,类似

export PORT=80 && npm start

EDIT: 编辑:

or even create you own start script on package.json 甚至在package.json上创建自己的启动脚本

"start80": "cross-env NODE_ENV=production PORT=80 node server",

(maybe- i dont' know exactly how cross-env works) (也许-我不知道跨环境的工作原理)

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

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