Having followed the 12devs of Xmas tutorial to create my first Node.js app (http://12devsofxmas.co.uk/post/2012-12-28-day-3-realtime-collaborative-drawing-with-nodejs) I'm now attempting to follow Rob Dodson's tutorial for deploying it through Heroku (http://robdodson.me/blog/2012/06/04/deploying-your-first-node-dot-js-and-socket-dot-io-app-to-heroku/)
However, after committing to github, when I attempt to push to Heroku, I get the following error output:
-----> Installing dependencies with npm
npm WARN package.json Draw@0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-2.5.11.tgz
npm http 200 https://registry.npmjs.org/express/-/express-2.5.11.tgz
npm ERR! Refusing to delete: /tmp/build_1t6d7hbd2psal/node_modules/.bin/express not in /tmp/build_1t6d7hbd2psal/node_modules/express
File exists: /tmp/build_1t6d7hbd2psal/node_modules/.bin/express
Move it away, and try again.
npm ERR! System Linux 2.6.32-350-ec2
npm ERR! command "/tmp/node-node-Fenl/bin/node" "/tmp/node-npm-6pyT/cli.js" "install" "--production"
npm ERR! cwd /tmp/build_1t6d7hbd2psal
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.65
npm ERR! path /tmp/build_1t6d7hbd2psal/node_modules/.bin/express
npm ERR! code EEXIST
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_1t6d7hbd2psal/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1
! Failed to install --production dependencies with npm
! Heroku push rejected, failed to compile Node.js app
To git@heroku.com:secure-dawn-2437.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:secure-dawn-2437.git'
My package.json file is as follows:
{
"name": "Draw",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "~2.x",
"socket.io": "~0.9.x"
},
"engines": {
"node": "0.6.x",
"npm": "1.1.x"
}
}
I'm sorry - I'm totally new to this sort of development, having mostly worked in Java while in school, but I'm anxious to learn. I assume the problem is somehow with express, but I'm not sure what it means by "move it away, and try again."
Do you have a Procfile file in your application you are trying to deploy?
If not, look at the documentation available on Heroku's Website:
https://devcenter.heroku.com/articles/nodejs#declare-process-types-with-procfile
EDIT:
I highly suggest you to deploy a really simple Node.js application at first (like a Hello World), just so you can trace back the source of your error.
Try removing bin and .bin from your .gitignore or adding node_modules to .gitignore. More info here: Fail to deploy node.js application to heroku
I was able to solve this by temporarily disabling Heroku's use of cache:
heroku config:set NODE_MODULES_CACHE=false
Push the build, then turn cache back on.