通过Heroku首次部署Node应用程序时出现问题

时间:2013-03-17 18:40:29

标签: node.js heroku express

按照圣诞节的12devs教程创建我的第一个Node.js应用程序(http://12devsofxmas.co.uk/post/2012-12-28-day-3-realtime-collaborative-drawing-with-nodejs)我现在正试图按照Rob Dodson的教程通过Heroku(http://robdodson.me/blog/2012/06/04/deploying-your-first-node-dot-js-and-socket-dot-io-app-to-heroku/)部署它

然而,在提交到github之后,当我尝试推送到Heroku时,我得到以下错误输出:

-----> 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'

我的package.json文件如下:

{
    "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"
    }
}

对不起 - 我对这种开发完全不熟悉,在学校里主要使用Java,但我很想学习。我认为这个问题在某种程度上是表达的,但是我不确定它是什么意思“将它移开,再试一次。”

3 个答案:

答案 0 :(得分:0)

您尝试部署的应用程序中是否有Procfile个文件?

如果没有,请查看Heroku网站上提供的文档:

https://devcenter.heroku.com/articles/nodejs#declare-process-types-with-procfile

修改

我强烈建议您首先部署一个非常简单的Node.js应用程序(如Hello World),这样您就可以追溯错误的来源。

答案 1 :(得分:0)

尝试从.gitignore中删除bin和.bin,或者将node_modules添加到.gitignore。更多信息:Fail to deploy node.js application to heroku

答案 2 :(得分:0)

我能够通过暂时禁用Heroku使用缓存来解决这个问题:

heroku config:set NODE_MODULES_CACHE=false

推送构建,然后重新打开缓存。