Heroku不读节点版本 [英] Heroku does not read node version

查看:138
本文介绍了Heroku不读节点版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Node项目,我想在Heroku上托管。我在我的package.json(位于根目录)中明确定义了node和npm版本,如下所示:

I have a Node project that I want to host on Heroku. I have explicitly defined node and npm versions in my package.json (located in the root directory), which looks like this:

{
  "name": "*********",
  "version": "0.0.0",
  "private": true,
  "engines": {
    "node": "0.12.x",
    "npm": "2.5.x"
  },
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "^1.13.3",
    ...
}

但是,当我尝试将应用推送到heroku时

However, when I try to push the app to heroku

git push heroku master 



Heroku试图构建应用程序,但似乎无法使用节点和npm版本。这是我收到的答复。

Heroku tries to build the app, but seems not to be able to reed the node and npm version. Here is the response i get.

remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:         
remote:        Resolving node version (latest stable) via semver.io...
remote:        Downloading and installing node 4.2.1...
remote:        Using default npm version: 2.14.7

为什么heroku不能从package.json读取节点和npm版本?

Why does heroku not read the node and npm version from package.json?

推荐答案

@rdegges是正确的,package.json没有正确地提交给Heroku。所以只是遵循Heroku的指示并不适合我。这是我为了使它工作所必须做的。

@rdegges was right that the package.json wasn't correctly committed to Heroku. So just following the Heroku instructions didn't work for me for some reason. Here is what I had to do in order to make it work.

git clone <my git project>
heroku create <app name>

#remove package.json
mv package.json tmp_package.json
git add package.json
git commit -m "removed package.json"

#re-add package.json
mv tmp_package.json package.json
git add package.json
git commit -m "re-added package.json"

git push heroku master

这篇关于Heroku不读节点版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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