Heroku:解决部署期间的npm错误-读取/tmp文件 [英] Heroku: troubleshooting npm errors during deploy - reading a /tmp file
问题描述
一些新的依赖项或其他一些可恶的事情导致npm在get push heroku master
部署期间出错:
Some new dependency or some other damn thing is causing npm to error during a get push heroku master
deploy:
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.10.1
Using npm version: 1.2.15
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
....
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_24pmtv04ok0ss/npm-debug.log
npm ERR! not ok code 0
not ok
的确如此.控制台上没有其他有用的信息,因此,我当然想查看该日志文件中的内容.
not ok
indeed. There's no other useful information printed to the console, so of course I want to see what's in that log file.
所以我尝试一下:
$ heroku run cat /tmp/build_24pmtv04ok0ss/npm-debug.log
但是,似乎没有这样的文件:
However, no such file appears to exist:
Running `cat /tmp/build_24pmtv04ok0ss/npm-debug.log` attached to terminal... up, run.3166
cat: /tmp/build_24pmtv04ok0ss/npm-debug.log: No such file or directory
因此,我的问题是:
- 日志文件在哪里?为什么我看不懂它?
- Heroku/npm是否还有其他方法可以在控制台上显示我的详细错误?
- 为什么完全相同的节点环境在本地可以正常运行,但是在Heroku上失败?
推荐答案
将代码推送到Heroku时,您的构建将在临时构建dyno上运行,因此一旦构建完成,所有文件都将消失,因为dynos具有临时文件系统. heroku run cat /tmp/build_24pmtv04ok0ss/npm-debug.log
无法提供帮助的原因是您附加了一次性dyno 与现有应用程序的全新文件系统(与dyno完全分离).
When you push code to Heroku, your build is run on a temporary build dyno, so once the build is complete, all the files are gone because dynos have an ephemeral file systems. The reason that heroku run cat /tmp/build_24pmtv04ok0ss/npm-debug.log
did not help is that that you attached to a one-off dyno with a fresh file system of your existing app (completely separate from the build dyno).
所有希望都不会丢失.通过调整buildpack 到cat
退出npm-debug.log
在这样的出口上:
All hope is not lost. You should be able to see what's going on by tweaking the buildpack to cat
out npm-debug.log
on exit like this:
function cat_npm_debug_log() {
if [ -f $BUILD_DIR/npm-debug.log ]; then
cat $BUILD_DIR/npm-debug.log
fi
}
trap cat_npm_debug_log EXIT
我还没有对它进行彻底的测试,但是我对 fork 做了一个快速的介绍. 默认节点构建包到将其设置为自定义buildpack 来进行尝试. :
I haven't thoroughly tested it, but I made a quick fork of the default Node buildpack to do what I just showed above. Feel free to try it out by setting it as a custom buildpack:
heroku config:add BUILDPACK_URL="https://github.com/ryanbrainard/heroku-buildpack-nodejs.git"
这篇关于Heroku:解决部署期间的npm错误-读取/tmp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!