Heroku节点/角度:部署应用程序和服务器

时间:2016-12-04 21:10:15

标签: node.js heroku npm travis-ci

我有简单的项目。 链接:https://github.com/Tyvain/BTCash

在本地我启动它:

npm install
cd BTCash/server/
node app.js
cd BTCash/
npm start

我尝试" github deployement"在heroku但得到了:

-----> Node.js app detected
-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error
   NPM_CONFIG_PRODUCTION=true
   NODE_ENV=production
   NODE_MODULES_CACHE=true
-----> Installing binaries
   engines.node (package.json):  unspecified
   engines.npm (package.json):   unspecified (use default)

   Resolving node version (latest stable) via semver.io...
   Downloading and installing node 6.9.1...
   Using default npm version: 3.10.8
-----> Restoring cache
   Skipping cache restore (new runtime signature)
-----> Building dependencies
   Installing node modules (package.json)

   > angular@1.0.0 postinstall /tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3
   > npm run typings install


   > angular@1.0.0 typings /tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3
   > typings "install"

   sh: 1: typings: not found

   npm ERR! Linux 3.13.0-100-generic
   npm ERR! argv "/tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/.heroku/node/bin/node" "/tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/.heroku/node/bin/npm" "run" "typings" "install"
   npm ERR! node v6.9.1
   npm ERR! npm  v3.10.8
   npm ERR! file sh
   npm ERR! code ELIFECYCLE
   npm ERR! errno ENOENT
   npm ERR! syscall spawn
   npm ERR! angular@1.0.0 typings: `typings "install"`
   npm ERR! spawn ENOENT
   npm ERR!
   npm ERR! Failed at the angular@1.0.0 typings script 'typings "install"'.
   npm ERR! Make sure you have the latest version of node.js and npm installed.
   npm ERR! If you do, this is most likely a problem with the angular package,
   npm ERR! not with npm itself.
   npm ERR! Tell the author that this fails on your system:
   npm ERR!     typings "install"
   npm ERR! You can get information on how to open an issue for this project with:
   npm ERR!     npm bugs angular
   npm ERR! Or if that isn't available, you can get their info via:
   npm ERR!     npm owner ls angular
   npm ERR! There is likely additional logging output above.

   npm ERR! Please include the following file with any support request:
   npm ERR!     /tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/npm-debug.log

   npm ERR! Linux 3.13.0-100-generic
   npm ERR! argv "/tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/.heroku/node/bin/node" "/tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/.npmrc"
   npm ERR! node v6.9.1
   npm ERR! npm  v3.10.8
   npm ERR! code ELIFECYCLE
   npm ERR! angular@1.0.0 postinstall: `npm run typings install`
   npm ERR! Exit status 1
   npm ERR!
   npm ERR! Failed at the angular@1.0.0 postinstall script 'npm run typings install'.
   npm ERR! Make sure you have the latest version of node.js and npm installed.
   npm ERR! If you do, this is most likely a problem with the angular package,
   npm ERR! not with npm itself.
   npm ERR! Tell the author that this fails on your system:
   npm ERR!     npm run typings install
   npm ERR! You can get information on how to open an issue for this project with:
   npm ERR!     npm bugs angular
   npm ERR! Or if that isn't available, you can get their info via:
   npm ERR!     npm owner ls angular
   npm ERR! There is likely additional logging output above.

   npm ERR! Please include the following file with any support request:
   npm ERR!     /tmp/build_7594b95a41ba0663394176646f6e85f5/Tyvain-BTCash-9a16ec3/npm-debug.log
-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   Some possible problems:

   - Node version not specified in package.json
   https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

   Love,
   Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed

我应该如何在heroku上部署和启动它?我应该使用travis CI吗?

1 个答案:

答案 0 :(得分:2)

NPM正在尝试运行npm run typings install安装后脚本,但typings包位于devDependencies的{​​{1}}部分。

由于Heroku上的package.json设置为“production”,因此不会安装这些包,因此无法在Heroku上完成NODE_ENV脚本。

尝试将npm postinstall移至typings中的dependencies部分。

另外,请阅读Heroku NodeJS development documentation了解更多有用的内容。例如,您应该在package.json

中指定NodeJS和NPM版本