今天我想将我的 node.js
应用程序部署到 heroku。在本地,我也在使用 bower
和 grunt
进行开发,我还想继续使用它们。
现在,根据我在网上找到的一些建议,我将 bower
添加到我的 dependencies
并添加了 "postinstall": "node_modules/.bin/bower install
到我的 package.json
postinstall
.
现在我遇到了 grunt
的一些问题。当我将 grunt 依赖项从 devDependencies
移动到 dependencies
时,grunt
无法识别我的 tasks
,例如当我有
{
"name": "js-linkedin-connector",
"version": "0.1.0",
"dependencies": {
"passport": "~0.1.17",
"passport-local": "~0.1.6",
"passport-linkedin-oauth2": "~1.0.1",
"connect": "~2.11.0",
"underscore": "~1.5.2",
"bower": "1.2.x",
"grunt": "~0.4.1",
"grunt-cli": "0.1.11",
"load-grunt-tasks": "~0.1.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-watch": "~0.5.2",
"grunt-autoprefixer": "~0.2.0",
"grunt-usemin": "~2.0.0",
"grunt-svgmin": "~0.2.0",
"grunt-rev": "~0.1.0",
"grunt-concurrent": "~0.3.0",
"grunt-jasmine-node": "~0.1.0",
"grunt-google-cdn": "~0.2.0",
"grunt-ngmin": "~0.0.2",
"time-grunt": "~0.1.0",
"grunt-karma": "~0.6.2",
"connect-livereload": "~0.3.0"
},
"devDependencies": {
"karma-ng-scenario": "~0.1.0",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3",
"karma-requirejs": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma": "~0.10.4",
"karma-ng-html2js-preprocessor": "~0.1.0"
},
"engines": {
"node": ">=0.8.0",
"npm": "1.3.x"
},
"scripts": {
"test": "grunt test",
"postinstall": "node_modules/.bin/bower install;node_modules/.bin/grunt server:dist"
}
}
在我的 package.json
中键入 ./node_modules/.bin/grunt
我得到:
Warning: Task "jshint" not found. Use --force to continue.
Aborted due to warnings.
但是当我将 grunt
依赖项移动到 devDependencies
时:
{
"name": "js-linkedin-connector",
"version": "0.1.0",
"dependencies": {
"passport": "~0.1.17",
"passport-local": "~0.1.6",
"passport-linkedin-oauth2": "~1.0.1",
"connect": "~2.11.0",
"underscore": "~1.5.2",
"bower": "1.2.x"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-cli": "0.1.11",
"load-grunt-tasks": "~0.1.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-coffee": "~0.7.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-compass": "~0.5.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-cssmin": "~0.6.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-htmlmin": "~0.1.3",
"grunt-contrib-watch": "~0.5.2",
"grunt-autoprefixer": "~0.2.0",
"grunt-usemin": "~2.0.0",
"grunt-svgmin": "~0.2.0",
"grunt-rev": "~0.1.0",
"grunt-concurrent": "~0.3.0",
"grunt-jasmine-node": "~0.1.0",
"grunt-google-cdn": "~0.2.0",
"grunt-ngmin": "~0.0.2",
"time-grunt": "~0.1.0",
"grunt-karma": "~0.6.2",
"connect-livereload": "~0.3.0",
"karma-ng-scenario": "~0.1.0",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.3",
"karma-requirejs": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"karma": "~0.10.4",
"karma-ng-html2js-preprocessor": "~0.1.0"
},
"engines": {
"node": ">=0.8.0",
"npm": "1.3.x"
},
"scripts": {
"test": "grunt test",
"postinstall": "node_modules/.bin/bower install;node_modules/.bin/grunt server:dist"
}
}
一切正常。
问题是什么以及如何解决它以将我的 grunt
+ bower
应用程序部署到 heroku?
最佳答案
将您的 Grunt 依赖项保存在它们所属的 devDependencies
中。使用 custom buildpack允许 Heroku 在他们的平台上执行您的 Grunt 流程。
Sample app that shows how to do exactly that
Buildpacks 让您以不同的方式启动应用程序,在这种情况下,您需要从配置设置中更改它:
heroku config:set BUILDPACK_URL=https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt.git
那么只需在您的 Grunt 配置中添加一个 heroku
任务即可。
关于node.js - heroku上的咕噜声和 bower ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20328428/