我正在做这个项目,但现在它已经完成,我想把它推给heroku.问题是让heroku启动应用程序.

在heroku示例中,演示服务器在从包含此数据的Procfile中获取信息后运行

web: node index.js

但在我的vuejs项目中,没有索引.为内容提供服务器的js.

我的主条目不是index.html,我只使用HTML.

推荐答案

你需要更新你的软件包.json文件,让heroku了解这些包,例如,如果您使用express来提供文件:

"scripts": {
   "postinstall": "npm install express"
 }
 // "start": "node server.js" (executing server.js) during start

server.js

var express = require('express')
var path = require('path')
var serveStatic = require('serve-static')

var app = express()
app.use(serveStatic(path.join(__dirname, 'dist')))

var port = process.env.PORT || 8000
app.listen(port)
console.log('server started ' + port)

别忘了build美元.

看看这里,阅读更多关于build conf:Customizing build process - Heroku的信息


npm install -g http-server

并更新Procfile以添加上述答案中提到的配置.

我只想知道:

  • npm install将同时安装"依赖项"和"devdependency"
  • npm安装--production将只安装"依赖项"
  • npm安装--dev将只安装"devdependences"

Vue.js相关问答推荐

如何用其他组件编译Vue模板?

Pinia+Vue 3状态react 性-StoreToRef的替代方案

如何默认打开一个v-list-group?

Svelte 中的简单react 性实验以意想不到的方式失败了. Vue 等效项没有

vue 计算的 ant watch 不会在嵌套属性更改时触发

Vuetify 复选框:如何停止点击事件?

在 VueJS 中存储图像的正确位置是什么 - 公共文件夹或assets文件夹?

使用 v-slot:body 时 Vuetify v-data-table 没有响应

使用 vue-cli 遇到无法推断解析器错误

如何在异步功能上使用 debounce?

在按键 vuejs 中只允许数字和一个小数点后 2 位限制

Vue.js 过滤数组

Vuetify 输入自动完成错误

如何在 Vue.js 3 中使用 Vue 3 Meta?

使用vue.js单击时如何获取按钮的值

如何在 Vue3 设置标签中定义组件名称?

所有 vue props和数据都给出错误 Property属性在 type 上不存在,带有 typescript

使计算的 Vue 属性依赖于当前时间?

Vue.JS 2.0 修改不相关数据时速度慢

为什么不能在 vue 模板中使用窗口?