繁体   English   中英

无法通过git将应用程序部署到heroku

[英]Having trouble deploying an app to heroku through git

我想在heroku上创建一个简单的node.js应用程序。 这是我的app.js:

 console.log("Starting App") const express = require('express') const app = express() const port = 3000 app.listen(process.env.PORT || port, () => console.log(`App listening on port ${port}!`)) app.get('/', (req,res) => { res.sendFile(__dirname+'/public/index.html') }) app.get('/style', (req,res) => { res.sendFile(__dirname+'/public/main.css') }) app.get('/script', (req,res) => { res.sendFile(__dirname+'/public/script.js') }) app.get('/changelog', (req,res) => { res.sendFile(__dirname+'/public/changelog.txt') }) 

这是我的package.json文件:

 { "name": "", "version": "0.0.0", "description": "", "main": "/App.js", "scripts": { "test": "echo \\"Error: no test specified\\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.16.4" } } 

这是我的Procfile:

web: node app.js

我通过github将它部署到heroku,每当我运行程序时它都会给我一个错误,说无法找到模块'/app/app.js。 我已将所有内容都设为小写并删除了正斜杠。 我仍然收到此错误:错误:找不到模块'/app/app.js'有人可以帮忙吗?

  1. 在package.json中,将"main": "/App.js" "main": "app.js"更改为"main": "app.js"
  2. 确保package.jsonapp.js处于同一级别
  3. 如果app.js位于另一个文件夹中,请确保提供包含package.json文件的目录的完整路径。

暂无
暂无

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

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