我向Heroku部署了一个使用gulp
的NodeJS应用,但它无法在Heroku上工作。
此处package.json
:
{
"name": "app-name",
"version": "1.0.0",
"previewUrl": "http://blahblah.com",
"publishUrl": "gs://blahblah.com",
"description": "",
"repository": {
"type": "git",
"url": "git://github.com/github_username/git_repo.git"
},
"devDependencies": {
"browser-sync": "*",
"browserify": "*",
"gulp": "*",
"gulp-autoprefixer": "*",
"gulp-changed": "*",
"gulp-filesize": "*",
"gulp-imagemin": "*",
"gulp-minify-css": "*",
"gulp-notify": "*",
"gulp-rev-all": "*",
"gulp-sass": "*",
"gulp-sourcemaps": "*",
"gulp-uglify": "*",
"gulp-util": "*",
"lodash": "*",
"pretty-hrtime": "*",
"require-dir": "*",
"velocity-animate": "^1.2.2",
"vinyl-source-stream": "*",
"watchify": "*"
},
"dependencies": {
"underscore": "~1.7.0",
"jquery": "~2.1.0",
"keen-js": "~3.2.4",
"superagent": "~1.2.0"
}
}
此处gulpfile.js
:
var requireDir = require('require-dir');
// Require all tasks in gulp/tasks, including subfolders
requireDir('./gulp/tasks', { recurse: true });
此处Procfile
:
`web: gulp`
当我部署到Heroku并转到托管应用程序的网站时,我得到了一个"应用程序失败"错误。当我检查我的Heroku日志时,这就是我所看到的:
2016-10-27T22:20:10.439111+00:00 heroku[web.1]: Starting process with command `gulp`
2016-10-27T22:20:12.282952+00:00 app[web.1]: bash: gulp: command not found
2016-10-27T22:20:12.376610+00:00 heroku[web.1]: Process exited with status 127
2016-10-27T22:20:12.371981+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-27T22:20:12.373134+00:00 heroku[web.1]: State changed from crashed to starting
2016-10-27T22:20:14.527034+00:00 heroku[web.1]: Starting process with command `gulp`
为什么应用会这样做?
答案 0 :(得分:0)
我可能错了,但我认为这是由于你的Procfile中gulp
的路径。
web: gulp
意味着您在远程计算机上全局安装了gulp
,而实际上每个Heroku构建都以新鲜的dyno开始(即没有对dyno的目的作出假设,因此存在很少,如果有的话,预先安装的模块超出了基础知识)。简而言之,它找不到gulp
作为全局安装的模块。
尝试更新Procfile以使用本地安装的gulp模块:web: ./node_modules/gulp/bin/gulp
。