简体   繁体   English

Node.js没有在Heroku上部署

[英]Node.js not deploying on Heroku

I've got a Node.JS+express app running using express-hbs. 我有一个使用express-hbs运行的Node.JS + express应用程序。 Everything works when running locally, but fails when deploying to Heroku. 在本地运行时一切正常,但在部署到Heroku时失败。

I have tried some of the obvious troubleshooting steps such as: 我尝试了一些明显的故障排除步骤,例如:

var port = process.env.PORT || 80;

But the issue still persists. 但问题仍然存在。

Here is the full error: 这是完整的错误:

/app/node_modules/express-hbs/lib/hbs.js:90
   var matches = str.match(layoutPattern);
 TypeError: Cannot read property 'match' of undefined
     at ExpressHbs.declaredLayoutFile (/app/node_modules/express-hbs/lib/hbs.js:90:21)
     at parseLayout (/app/node_modules/express-hbs/lib/hbs.js:476:27)
     at /app/node_modules/express-hbs/lib/hbs.js:598:7
     at getSourceTemplate (/app/node_modules/express-hbs/lib/hbs.js:572:16)
     at compileFile (/app/node_modules/express-hbs/lib/hbs.js:594:5)
     at /app/node_modules/express-hbs/lib/hbs.js:647:16
     at ReaddirpReadable.<anonymous> (/app/node_modules/express-hbs/lib/hbs.js:196:17)
     at emitNone (events.js:106:13)
     at ReaddirpReadable.emit (events.js:208:7)
     at endReadableNT (/app/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1

Locally I am running Node.js v6.11.4 and NPM v3.10.10, both of which are included in package.json 本地我运行Node.js v6.11.4和NPM v3.10.10,这两个都包含在package.json中

This may be an issue with you package-lock.json file getting out of sorts... Especially, since the error is originating from within your express-hbs node module: 这可能是一个问题与您package-lock.json文件越来越不舒服......尤其是,由于错误是从内发起express-hbs节点模块:

app/node_modules/express-hbs/lib/hbs.js:90 应用程序/ node_modules /快递-HBS / lib目录/ hbs.js:90

Maybe you could try deleting your local package-lock.json file, as well as your node_modules directory, and then try reinstalling your dependent libraries? 也许你可以尝试删除你的本地package-lock.json文件,以及你的node_modules目录,然后尝试重新安装你的依赖库?

For example, once your package-lock.json and node_modules have been deleted: 例如,一旦删除了package-lock.jsonnode_modules

rm package-lock.json
rm -rf node_modules

Try reinstalling your project's dependent npm libraries with an: npm install 尝试使用: npm install 重新安装项目的相关npm

Once these libraries have been reinstalled, you will have a fresh up-to-date package-lock.json file, since this file is autogenerated and serves almost like the " source of truth " for the building of your project to others. 重新安装这些库后,您将拥有一个全新的package-lock.json文件,因为该文件是自动生成的,并且几乎就像是为其他人构建项目的“ 真实来源 ”。 Now try pushing and publishing your code to Heroku and see if this resolves your issue. 现在尝试代码推送并发布Heroku ,看看这是否可以解决您的问题。

Hopefully that helps! 希望这有帮助!

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

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