- I have a fork of a Node.js module on GitHub that is a depenency of an app.
- That module is written in CoffeeScript. When 'npm install' downloads it, it doesn't compile the module. This is a problem when deploying the app to Heroku, because I can't compile it when deploying to Heroku.
- Furthermore, compiling the module has its own depenencies. The dependencies need to be installed before it can be installed.
- If I manually run 'npm install' in the forked module's directory inside node_modules, then 'grunt prepublish', everything will work.
- I need to automate step #4 when installing the app. How do I do that?
The app in question is https://github.com/sillygwailo/Slack-Twitter If you run npm install in that directory, the slack-client module will not get compiled.
The soution to this was to do the following:
- Make 'grunt' and 'grunt-cli' dependencies of the app.
- Move the module's dependencies in its package.json file from 'devDependencies' to just 'dependencies'.
- Create a postinstall "script", which amounts to:
- cd node_modules/moduledirectory # change into the module's directory
- npm install # install the module's dependencies
- ../grunt-cli/bin grunt prepublish # run grunt, provided by the app's dependencies, to compile the CoffeeScript module
All this became moot once the module accepted my pull request. Suffice to say, it is possible to compile a forked version of a Node.js module written in CoffeeScript without committing the compiled JavaScript to your fork