我遵循了Heroku上Node.js的基本开始指令:
https://devcenter.heroku.com/categories/nodejs
这些指令并没有告诉你创建一个.gitignore node_modules,因此暗示文件夹node_modules应该签入Git。当我在Git存储库中包含node_modules时,我的入门应用程序正确运行。
当我遵循更高级的例子在:
它指示我将文件夹node_modules添加到文件.gitignore中。所以我从Git中删除了文件夹node_modules,将其添加到文件.gitignore中,然后重新部署。这次部署失败了,如下所示:
-----> Heroku receiving push
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.8.2
Using npm version: 1.0.106
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
Error: npm doesn't work with node v0.8.2
Required: node@0.4 || 0.5 || 0.6
at /tmp/node-npm-5iGk/bin/npm-cli.js:57:23
at Object.<anonymous> (/tmp/node-npm-5iGk/bin/npm-cli.js:77:3)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/tmp/node-npm-5iGk/cli.js:2:1)
at Module._compile (module.js:449:26)
Error: npm doesn't work with node v0.8.2
Required: node@0.4 || 0.5 || 0.6
at /tmp/node-npm-5iGk/bin/npm-cli.js:57:23
at Object.<anonymous> (/tmp/node-npm-5iGk/bin/npm-cli.js:77:3)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/tmp/node-npm-5iGk/cli.js:2:1)
at Module._compile (module.js:449:26)
Dependencies installed
-----> Discovering process types
Procfile declares types -> mongod, redis, web
-----> Compiled slug size is 5.0MB
-----> Launching... done, v9
跑步“heroku ps”;证实了坠机。好的,没有问题,所以我回滚了更改,将文件夹node_module添加回Git存储库,并从文件.gitignore中删除它。但是,即使在恢复之后,我仍然在部署时得到相同的错误消息,但现在应用程序再次正确运行了。跑步“heroku ps”;告诉我应用程序正在运行。
正确的做法是什么?是否包含文件夹node_modules ?为什么回滚时仍然会得到错误消息?我猜Heroku这边的Git仓库状态很差。