Giter Club home page Giter Club logo

heroku-buildpack-nodejs-grunt's Introduction

Heroku buildpack: Node.js with Grunt support

Note: this buildpack is no longer maintained

Using Heroku's official Node.js buildpack with a postinstall script, that executes your Gruntfile is the suggested way on building Node.js with Grunt.

Follow the official guide for details and instructions.





(outdated) Introduction

Supported Grunt versions: 0.3 and 0.4. See the Grunt migration guide if you are upgrading from 0.3.

This is a fork of Heroku's official Node.js buildpack with added Grunt support. Using this buildpack you do not need to commit the results of your Grunt tasks (e.g. minification and concatination of files), keeping your repository clean.

After all the default Node.js and npm build tasks have finished, the buildpack checks if a Gruntfile (Gruntfile.js, Gruntfile.coffeeor grunt.js) exists and executes the heroku task by running grunt heroku. For details about grunt and how to define tasks, check out the offical documentation. You must add grunt to the npm dependencies in your package.json file. If no Gruntfile exists, the buildpacks simply skips the grunt step and executes like the standard Node.js buildpack.

How it Works

Here's an overview of what this buildpack does:

  • Uses the semver.io webservice to find the latest version of node that satisfies the engines.node semver range in your package.json.
  • Allows any recent version of node to be used, including pre-release versions.
  • Uses an S3 caching proxy of nodejs.org for faster downloads of the node binary.
  • Discourages use of dangerous semver ranges like * and >0.10.
  • Uses the version of npm that comes bundled with node.
  • Puts node and npm on the PATH so they can be executed with heroku run.
  • Caches the node_modules directory across builds for fast deploys.
  • Doesn't use the cache if node_modules is checked into version control.
  • Runs npm rebuild if node_modules is checked into version control.
  • Always runs npm install to ensure npm script hooks are executed.
  • Always runs npm prune after restoring cached modules to ensure cleanup of unused dependencies.
  • Runs grunt if a Gruntfile (Gruntfile.js, Gruntfile.coffeeor grunt.js) is found.

For more technical details, see the heavily-commented compile script.

Usage

Create a new app with this buildpack:

heroku create myapp --buildpack https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt.git

Or add this buildpack to your current app:

heroku buildpacks:set https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt.git

Set the NODE_ENV environment variable (e.g. development or production):

heroku config:set NODE_ENV=production

Create your Node.js app and add a Gruntfile named Gruntfile.js (or Gruntfile.coffee if you want to use CoffeeScript, or grunt.js if you are using Grunt 0.3) with a heroku task:

grunt.registerTask('heroku:development', 'clean less mincss');

or

grunt.registerTask('heroku:production', 'clean less mincss uglify');

Don't forget to add grunt to your dependencies in package.json. If your grunt tasks depend on other pre-defined tasks make sure to add these dependencies as well:

"dependencies": {
    ...
    "grunt": "*",
    "grunt-contrib": "*",
    "less": "*"
}

Push to heroku

git push heroku master
...
-----> Heroku receiving push
-----> Fetching custom buildpack... done
-----> Node.js app detected
-----> Resolving engine versions
       Using Node.js version: 0.8.2
       Using npm version: 1.1.41
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
       ...
       Dependencies installed
-----> Building runtime environment
-----> Found gruntfile, running grunt heroku task
Running "heroku" task
...
-----> Discovering process types

Debugging

npm can be run with a verbose flag to help debugging if something fails when installing the dependencies.

  • if the VERBOSE environment variable is set, npm is always run with verbose logging.
  • if BUILDPACK_RETRY_VERBOSE is set, npm is relaunched in verbose mode if npm failed.

Thanks to mackwic for these extensions.

Further Information

For more information about using Node.js and buildpacks on Heroku, see these Dev Center articles:

heroku-buildpack-nodejs-grunt's People

Contributors

bripkens avatar btubbs avatar cleishm avatar coreyjonoliver avatar davidjrice avatar ddollar avatar dzuelke avatar edo78 avatar ekryski avatar flyerhzm avatar gvelo avatar hmnimk avatar hone avatar jacobwgillespie avatar jclem avatar lackac avatar mbuchetics avatar mmcgrana avatar ryanbrainard avatar rykov avatar skeller88 avatar timshadel avatar zbuc avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

heroku-buildpack-nodejs-grunt's Issues

Issue with path to compass binary

I'm using heroku-buildpack-multi to install compass library (Ruby) for Node.js app. I've been using Heroku Ruby and Node.js buildpacks and it worked fine. I switched to this one and suddenly Grunt task complains that it can't find compass binary:

Warning: Running "compass:dist" (compass) task
Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Use --force to continue.

It looks like compass is correctly installed to /app/vendor/bundle/bin/compass and /app/vendor/bundle/bin is in PATH.

Any idea what might be the problem?

Failing to install grunt-cli dependencies

I kept getting this error when I tried to commit to heroku:

   npm http GET https://registry.npmjs.org/grunt-cli
   npm http 200 https://registry.npmjs.org/grunt-cli
   npm http GET https://registry.npmjs.org/grunt-cli/-/grunt-cli-0.1.9.tgz
   npm http 200 https://registry.npmjs.org/grunt-cli/-/grunt-cli-0.1.9.tgz
   npm http GET https://registry.npmjs.org/resolve
   npm http GET https://registry.npmjs.org/findup-sync
   npm http GET https://registry.npmjs.org/nopt
   npm http 200 https://registry.npmjs.org/findup-sync
   npm http GET https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.2.tgz
   npm http 200 https://registry.npmjs.org/nopt
   npm http GET https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
   npm http 200 https://registry.npmjs.org/resolve
   npm http GET https://registry.npmjs.org/resolve/-/resolve-0.3.1.tgz
   npm http 200 https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.2.tgz
   npm http 200 https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
   npm http 200 https://registry.npmjs.org/resolve/-/resolve-0.3.1.tgz
   npm http GET https://registry.npmjs.org/abbrev
   npm http GET https://registry.npmjs.org/glob
   npm http GET https://registry.npmjs.org/lodash
   npm http 200 https://registry.npmjs.org/abbrev
   npm http GET https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
   npm http 200 https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
   npm ERR! cb() never called!
   npm ERR! not ok code 0

! Failed to install grunt-cli dependencies with npm

! Push rejected, failed to compile Node.js app

This only recently started happening. I spent about two hours trying to fix the issue (reinstalling grunt versions, etc), but in the end I just ran grunt manually and removed the buildpack, and it worked just fine.

My package.json specifies:
"engines": {
"node": "0.10.x",
"npm": "1.2.x"
}
and
"grunt": "~0.3.17",
"grunt-less": ">0.0.0",
"grunt-css": "0.2.1"

Let me know if I can give you any more information.

Allow setting NPM version in engines

Thuis buildpack ignores the npm setting in engine in package.json, causing issues for builds that break on peerDependencies (npm 3+ just generates a warning, instead of an error)

Fatal error: Unable to find local grunt

Hey @mbuchetics !

Using your heroku buildpack i'm getting the following error, after buildpack is fetched and installed:

Unable to find local grunt

grunt is defined in my package.json und dependencies. Is there anything else I'm missing?

Fails to run npm rebuild?

I'm not quite sure what is happening, but bcrypt is giving me an error that makes me think that "npm rebuild" is not being run properly. I set the following engine in package.json:

node: 0.10.25
npm: 1.3.21

And to temporarily fix the error, I changed my procfile:
web: npm rebuild && node server.js

And it works. This leads me to believe that somehow npm rebuild is not being properly run.

Typically, people use devDependencies for grunt components

And it's kind of a hassle to add these dependencies to production as well -- so I'm thinking it might be a good idea to ensure that the devDependencies are installed, but the correct heroku:<NODE_ENV> task is still used?

I'm not totally sure in my head how this would work, since we can't tell heroku to change the value of NODE_ENV during compilation and deployment, as far as I can tell

node modules cache

i really like this feature, but how to re-cache the node modules? i have changed the package.json and added a new package, but it is still using the cache. is there a way to "rebuild" the cache?

Adding bower support

My NodeJS app includes the server and client code, is it possible to add bower install phase before running the grunt task?

NPM install failure: ENOTDIR error when pushing to Heroku

I'm fairly new to Heroku/buildpacks in general, and am having some trouble with dependency installation.

Here's a snapshot of the log:

-----> Installing dependencies with npm
       npm WARN package.json [email protected] No repository field.
       npm WARN package.json [email protected] No README data
       npm http GET https://registry.npmjs.org/grunt-contrib-watch
       npm http GET https://registry.npmjs.org/grunt
       npm http GET https://registry.npmjs.org/grunt-contrib-compass
       npm http GET https://registry.npmjs.org/grunt-express-server
       npm http GET https://registry.npmjs.org/grunt-usemin
       npm http GET https://registry.npmjs.org/grunt-contrib-concat
       npm http GET https://registry.npmjs.org/grunt-contrib-uglify
       npm http GET https://registry.npmjs.org/grunt-contrib-cssmin
       npm http GET https://registry.npmjs.org/grunt-contrib-copy
       npm http GET https://registry.npmjs.org/ejs
       npm http GET https://registry.npmjs.org/express
       npm http 200 https://registry.npmjs.org/grunt-express-server
       npm ERR! Error: ENOTDIR, mkdir '/tmp/build_a3a0b3d1-a80c-4b94-a140-acac62daad91/tmp/npm-521-IQxgUMLu/1388700135912-0.03680832404643297'
       npm ERR! If you need help, you may report this log at:
       npm ERR!     <http://github.com/isaacs/npm/issues>
       npm ERR! or email it to:
       npm ERR!     <[email protected]>

       npm ERR! System Linux 3.8.11-ec2
       npm ERR! command "/tmp/node-node-g8IG/bin/node" "/tmp/node-npm-olhA/cli.js" "install"
       npm ERR! cwd /tmp/build_a3a0b3d1-a80c-4b94-a140-acac62daad91
       npm ERR! node -v v0.10.10
       npm ERR! npm -v 1.3.11
       npm ERR! path /tmp/build_a3a0b3d1-a80c-4b94-a140-acac62daad91/tmp/npm-521-IQxgUMLu/1388700135912-0.03680832404643297
       npm ERR! code ENOTDIR
       npm ERR! errno 27
       npm http 200 https://registry.npmjs.org/grunt
       npm http 200 https://registry.npmjs.org/grunt-contrib-compass
       npm http 200 https://registry.npmjs.org/grunt-usemin
       npm http 200 https://registry.npmjs.org/grunt-contrib-watch
       npm http 200 https://registry.npmjs.org/grunt-contrib-concat
       npm http 200 https://registry.npmjs.org/grunt-contrib-cssmin
       npm http 200 https://registry.npmjs.org/grunt-contrib-uglify
       npm http 200 https://registry.npmjs.org/grunt-contrib-copy
       npm http 200 https://registry.npmjs.org/ejs
       npm http 200 https://registry.npmjs.org/express
       npm ERR!
       npm ERR! Additional logging details can be found in:
       npm ERR!     /tmp/build_a3a0b3d1-a80c-4b94-a140-acac62daad91/npm-debug.log
       npm ERR! not ok code 0
 !     Failed to install dependencies with npm

 !     Push rejected, failed to compile Node.js app

I've been googling to no avail, and I'm afraid I'm hitting a wall with my limited Heroku knowledge. Can anyone shine some light?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.