无法将 node.js 应用程序部署到 heroku [英] Fail to deploy node.js application to heroku

查看:33
本文介绍了无法将 node.js 应用程序部署到 heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个简单的基于 node.js express 的应用程序部署到 heroku,这显然是非常基本的:https://devcenter.heroku.com/articles/nodejs

I am trying to deploy a simple node.js express-based application to heroku, something which is apparently very basic: https://devcenter.heroku.com/articles/nodejs

这是我的 package.json:

Here is my package.json:

{
  "name": "cours-lic3-blois",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "dependencies": {
    "express": "*",
    "ejs": "*",
    "github-flavored-markdown": "*",
    "less-middleware": "*"
  },
  "engines": {
    "node": "0.8.8",
    "npm": "1.1.65"
  }
}

当我 git push heroku master 我得到以下跟踪:

When I git push heroku master I got the following trace:

 -----> Heroku receiving push
 -----> Node.js app detected
 -----> Resolving engine versions
        Using Node.js version: 0.8.8
        Using npm version: 1.1.65
 -----> Fetching Node.js binaries
 -----> Vendoring node into slug
 -----> Installing dependencies with npm
        npm ERR! Error: ENOENT, chmod '/tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express'
        npm ERR! If you need help, you may report this log at:
        npm ERR!     <http://github.com/isaacs/npm/issues>
        npm ERR! or email it to:
        npm ERR!     <npm-@googlegroups.com>

        npm ERR! System Linux 2.6.32-348-ec2
        npm ERR! command "/tmp/node-node-tonf/bin/node" "/tmp/node-npm-NG88/cli.js" "rebuild"
        npm ERR! cwd /tmp/build_1suuxlhd9s8n6
        npm ERR! node -v v0.8.8
        npm ERR! npm -v 1.1.65
        npm ERR! path /tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express
        npm ERR! code ENOENT
        npm ERR! errno 34
        npm ERR!
        npm ERR! Additional logging details can be found in:
        npm ERR!     /tmp/build_1suuxlhd9s8n6/npm-debug.log
        npm ERR! not ok code 0
  !     Failed to rebuild dependencies with npm
  !     Heroku push rejected, failed to compile Node.js app

 To git@heroku.com:fast-everglades-2007.git
  ! [remote rejected] master -> master (pre-receive hook declined)
 error: failed to push some refs to 'git@heroku.com:fast-everglades-2007.git'

我尝试调整 package.json 中的各种版本,但无济于事.我正在 Windows 上开发,这个 ENOENT 问题可能是由于某些文件模式问题造成的.

I tried to tweak various versions in my package.json but to no avail. I am developing on windows and it might be possible this ENOENT issue is due to some filemode issue.

推荐答案

我通过以下方式解决了这个问题:

I got this fixed by:

  • 确保 Procfile 已提交到 git

  • Making sure Procfile is committed into git

删除 node_modules/文件夹并将其提交到 git (git rm -r node_modules/)

Removing the node_modules/ folder and committing that into git (git rm -r node_modules/)

之后,我做了 git push heroku master 然后错误消失了.

Afterwards, I did the git push heroku master then the error disappeared.

这篇关于无法将 node.js 应用程序部署到 heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆