【问题标题】:Heroku node / angular: deploy app and serverHeroku 节点/角度:部署应用程序和服务器
【发布时间】:2016-12-13 12:06:02
【问题描述】:

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

在本地我是这样启动的:

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

我在 heroku 中尝试“github deployement”但得到了:

-----> 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 吗?

【问题讨论】:

    标签: node.js heroku npm travis-ci


    【解决方案1】:

    NPM 正在尝试运行 npm run typings install 安装后脚本,但 typings 包位于 devDependencies 部分中的 package.json

    由于 Heroku 上的 NODE_ENV 设置为“生产”,因此不会安装这些软件包,因此 npm postinstall 脚​​本将无法在 Heroku 上完成。

    尝试将typings 移动到package.json 中的dependencies 部分。

    另外,阅读Heroku NodeJS development documentation 了解更多有用的信息。例如,您确实应该在 package.json 中指定 NodeJS 和 NPM 版本。

    【讨论】:

      猜你喜欢
      • 2020-04-18
      • 2021-07-07
      • 2016-11-19
      • 1970-01-01
      • 2015-02-28
      • 2020-08-22
      • 1970-01-01
      • 1970-01-01
      • 2018-03-05
      相关资源
      最近更新 更多