Deploying to heroku - sensitive to correct node module versions

All,
I just moved an existing application to Phoenix 1.3 and re-deployed to Heroku. I found the deployment was very sensitive to node module versions so I wanted to post here for anyone running in to similar issues.

Heroku was choosing:
Erlang 19.3
Elixir 1.4.2
node v6.9.2
npm v3.10.9

I also included .elixir_buildpack.config with a “always_rebuild=true” flag and .phoenix_static_buildpack.config with a “clean_cache=true” flag to try to ensure that heroku was building from scratch on each deploy.

Everything was fine locally, but here are some of the errors I saw on deployment. I believe these are all related to Brunch and npm:

1.) remote: Brunch: Local install exists, but failed to load it. Continuing with global install: { Error: Cannot find module ‘./utils/error’
remote: at Function.Module._resolveFilename (module.js:469:15)
remote: at Function.Module._load (module.js:417:25)
remote: at Module.require (module.js:497:17)
remote: at require (internal/module.js:20:19)
remote: at Object. (/tmp/build_844e9bf7da5aa826f2f4f7588e7b1bd8/assets/node_modules/brunch/lib/index.js:5:21)remote: at Module._compile (module.js:570:32)
remote: at Object.Module._extensions…js (module.js:579:10)
remote: at Module.load (module.js:487:32)
remote: at tryModuleLoad (module.js:446:12)
remote: at Function.Module._load (module.js:438:3) code: ‘MODULE_NOT_FOUND’ }
remote: module.js:471
remote: throw err;
remote: ^
remote:
remote: Error: Cannot find module ‘./utils/error’

1.) Solution - I believe this was fixed by bumping the brunch version from 2.10.5 to 2.10.7

2.) remote: npm ERR! Linux 3.13.0-112-generic
remote: npm ERR! argv “/tmp/build_9fda396d33d7e578b6aad5626a7f44dc/.heroku/node/bin/node” “/tmp/build_9fda396d33d7e578b6aad5626a7f44dc/.heroku/node/bin/npm” “rebuild”
remote: npm ERR! node v6.9.2
remote: npm ERR! npm v3.10.9
remote: npm ERR! path /tmp/build_9fda396d33d7e578b6aad5626a7f44dc/assets/node_modules/clean-css/bin/cleancss
remote: npm ERR! code ENOENT
remote: npm ERR! errno -2
remote: npm ERR! syscall chmod
remote:
remote: npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/build_9fda396d33d7e578b6aad5626a7f44dc/assets/node_modules/clean-css/bin/cleancss

2.) Solution - I believe this was fixed by bumping the clean-css-brunch version to 2.10.0

Overall - here’s the package.json that worked for me with Sass (phoenix 1.3, so its /assets/package.json)

{
“repository”: {},
“license”: “MIT”,
“scripts”: {
“deploy”: “brunch build --production”,
“watch”: “brunch watch --stdin”
},
“dependencies”: {
“phoenix”: “file:…/deps/phoenix”,
“phoenix_html”: “file:…/deps/phoenix_html”
},
“devDependencies”: {
“babel-brunch”: “6.0.6”,
“brunch”: “2.10.7”,
“clean-css-brunch”: “2.10.0”,
“uglify-js-brunch”: “2.10.0”,
“sass-brunch”: “^2.10.4”
}
}

Hope this helps someone!

Jeff

2 Likes