2

按照 12devs of Xmas 教程创建我的第一个 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-应用程序到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 工作,但我很想学习。我认为问题出在 express 上,但我不确定“将其移开,然后重试”是什么意思。

4

3 回答 3

0

我可以通过暂时禁用 Heroku 对缓存的使用来解决这个问题:

heroku config:set NODE_MODULES_CACHE=false

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

于 2015-03-13T18:49:57.857 回答
0

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

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

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

编辑:

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

于 2013-03-17T19:38:41.383 回答
0

尝试从 .gitignore 中删除 bin 和 .bin 或将 node_modules 添加到 .gitignore。更多信息:无法将 node.js 应用程序部署到 heroku

于 2013-04-05T02:01:11.723 回答