我想知道是否有可能运行一个grunt-命令,以便使用Heroku为您的静态文件提供服务。
我的Grunt文件如下:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
server: {
options: {
port: process.env.PORT || 5000,
base: 'www',
keepalive: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
// Default task(s).
grunt.registerTask('default', ['connect']);
};我的过程文件如下所示:
web: grunt我的package.json看起来是这样的:
{
"name": "herokoloco",
"version": "0.1.1",
"scripts": {
"postinstall": "bower install"
},
"dependencies": {
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-contrib-connect": "^0.8.0",
"bower": "~1.3.9"
},
"engines": {
"node": "0.10.x"
}
}我的文件结构如下所示:
> node_modules
v www
index.html
bower.json
Gruntfile.js
package.json
Procfile它在本地使用Heroku的“工头开始网络”,但在Heroku上不起作用。我只是在日志中发现了这个错误:
2014-10-08T21:19:23.620448+00:00 herokurouter: at=error code=H14 desc=“没有运行”method=GET path="/“主机=屏蔽-waters 3266.herokuapp.com fwd="198.245.95.126”dyno= connect= service= status=503 bytes=
发布于 2014-10-10 21:34:48
一旦我真的设置了一些dynos,它就起作用了。为此,我从Heroku项目的终端发出了以下命令:
heroku ps:scale web=1发布于 2013-05-13 01:35:47
通过在Procfile中设置启动服务器的命令,可以让Heroku在完成安装后运行任何您想要的命令。所以,就像:
web: ./node_modules/grunt/.bin/grunt my-grunt-command ; node app.js应该行得通。
发布于 2014-03-19 11:12:54
确保在包配置(包括grunt-cli)中列出了所有的基本依赖项,确保删除连接配置的hostname部分并使用进程端口。ie“端口:在您连接信任关系中的process.env.PORT收5000”。这对我有用。
https://stackoverflow.com/questions/16434033
复制相似问题