Node.js在Heroku上入门

时间:2018-11-03 20:38:23

标签: heroku

在使用Heroku /编程方面,我是一个极端的初学者。我正在尝试按照有关Heroku入门和部署Node.js应用程序的说明进行操作。一切正常,直到需要修改应用程序为止(下面的链接)。

https://devcenter.heroku.com/articles/getting-started-with-nodejs#push-local-changes

我用推荐的代码编辑了index.js文件,但是当我在本地测试并访问该应用程序时,我得到以下信息:

无法获取/ cool

我缺少一个步骤吗?

这是我的index.js文件中的代码:

const cool = require('cool-ascii-faces')
const express = require('express')
const path = require('path')
const PORT = process.env.PORT || 5000

express()
  .use(express.static(path.join(__dirname, 'public')))
  .set('views', path.join(__dirname, 'views'))
  .set('view engine', 'ejs')
  .get('/', (req, res) => res.render('pages/index'))
  .get('/cool', (req, res) => res.send(cool()))
  .listen(PORT, () => console.log(`Listening on ${ PORT }`))

1 个答案:

答案 0 :(得分:0)

请确保您确实修改了在本地实例上运行的实际index.js文件(您可能还使用NetBeans /其他地方克隆了该存储库)