Heroku不读取节点版本

nus*_*sic 14 json heroku node.js package.json

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

{
  "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",
    ...
}
Run Code Online (Sandbox Code Playgroud)

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

git push heroku master 
Run Code Online (Sandbox Code Playgroud)

Heroku尝试构建应用程序,但似乎无法reed节点和npm版本.这是我得到的回应.

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
Run Code Online (Sandbox Code Playgroud)

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

nus*_*sic 7

@rdegges是对的,因为package.json没有正确地提交给Heroku.因此,仅仅遵循Heroku说明因某些原因对我不起作用.这是我必须做的才能使它工作.

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
Run Code Online (Sandbox Code Playgroud)