node.js - heroku推送被拒绝无法编译node.js应用程序

标签 node.js heroku heroku-toolbelt

我在推送到 heroku 时收到以下错误消息:

Counting objects: 21, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (19/19), done.
Writing objects: 100% (21/21), 3.44 KiB, done.
Total 21 (delta 5), reused 0 (delta 0)

-----> Node.js app detected
-----> Resolving engine versions

   WARNING: No version of Node.js specified in package.json, see:
   https://devcenter.heroku.com/articles/nodejs-versions

   Using Node.js version: 0.10.5
   Using npm version: 1.2.18
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
   npm ERR! install Couldn't read dependencies
   npm ERR! Failed to parse json
   npm ERR! Unexpected token }
   npm ERR! File: /tmp/build_1nxuppeok7fl7/package.json
   npm ERR! Failed to parse package.json data.
   npm ERR! package.json must be actual JSON, not just JavaScript.
   npm ERR! 
   npm ERR! This is not a bug in npm.
   npm ERR! Tell the package author to fix their package.json file. JSON.parse

   npm ERR! System Linux 2.6.32-350-ec2
   npm ERR! command "/tmp/node-node-8tU8/bin/node" "/tmp/node-npm-iUEr/cli.js" "install" "--production"
   npm ERR! cwd /tmp/build_1nxuppeok7fl7
   npm ERR! node -v v0.10.5
   npm ERR! npm -v 1.2.18
   npm ERR! file /tmp/build_1nxuppeok7fl7/package.json
   npm ERR! code EJSONPARSE
   npm ERR! 
   npm ERR! Additional logging details can be found in:
   npm ERR!     /tmp/build_1nxuppeok7fl7/npm-debug.log
   npm ERR! not ok code 0
   !     Failed to install --production dependencies with npm
   0 info it worked if it ends with ok
   1 verbose cli [ '/tmp/node-node-8tU8/bin/node',
   1 verbose cli   '/tmp/node-npm-iUEr/cli.js',
   1 verbose cli   'install',
   1 verbose cli   '--production' ]
   2 info using <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ce2fce1ccbda2bea2bdb4" rel="noreferrer noopener nofollow">[email protected]</a>
   3 info using <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="66080902032610564857564853" rel="noreferrer noopener nofollow">[email protected]</a>
   4 verbose read json /tmp/build_1nxuppeok7fl7/package.json
   5 error install Couldn't read dependencies
   6 error Failed to parse json
   6 error Unexpected token }
   7 error File: /tmp/build_1nxuppeok7fl7/package.json
   8 error Failed to parse package.json data.
   8 error package.json must be actual JSON, not just JavaScript.
   8 error
   8 error This is not a bug in npm.
   8 error Tell the package author to fix their package.json file. JSON.parse
   9 error System Linux 2.6.32-350-ec2
   10 error command "/tmp/node-node-8tU8/bin/node" "/tmp/node-npm-iUEr/cli.js"          "install" "--production"
   11 error cwd /tmp/build_1nxuppeok7fl7
   12 error node -v v0.10.5
   13 error npm -v 1.2.18
   14 error file /tmp/build_1nxuppeok7fl7/package.json
   15 error code EJSONPARSE
   16 verbose exit [ 1, true ]
   !     Heroku push rejected, failed to compile Node.js app

  To <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8bece2ffcbe3eef9e4e0fea5e8e4e6" rel="noreferrer noopener nofollow">[email protected]</a>:hidden-hamlet-7335.git
  ! [remote rejected] master -> master (pre-receive hook declined)
  error: failed to push some refs to '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f5929c81b59d90879a9e80db969a98" rel="noreferrer noopener nofollow">[email protected]</a>:hidden-hamlet-7335.git'

这是我的 package.json(如果您想知道我已在本地安装了依赖项并且 package.json 有效)

  {
    "name": "Simple-chat-application",
    "version": "0.0.1",
    "private": true,
    "scripts": {
      "start": "node app"
    },
    "dependencies": {
      "express": "3.1.0",
      "jade": "0.28.1",
      "socket.io": "0.9.13"
    },
    "engines": {
      "node": "0.10.x",
      "npm": "1.2.x"
    }
 }

最佳答案

问题出在 git add 上。我忘记添加 node_modules 文件。我关闭了终端并再次运行了 Heroku 和 NodeJs 入门 [1] 中给出的命令集。应用程序已成功推送到堆栈。

[1]- https://devcenter.heroku.com/articles/nodejs

关于node.js - heroku推送被拒绝无法编译node.js应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16425628/

相关文章:

node.js - 当部分测试模块化为不同的函数时,Nodejs 测试给出错误

ruby - zsh:不再找到 Heroku 工具带

ruby-on-rails - 在 ubuntu 14.04 中执行命令 "ERROR: EOF"时,heroku 版本给出了错误 "heroku version"?

javascript - 使用 javascript/node js 获取用户的所有公共(public) github 存储库

Node.js 监听 session 变量变化并触发服务器发送的事件

ruby-on-rails - heroku - 我不想在本地安装 postgres!

docker - 我可以使用 Heroku 容器 :push? 指定自定义 Dockerfile 名称吗

ruby-on-rails - 远程或直接提供图像到 Amazon S3 - Dragonfly Gem

docker - Heroku:如何在 gitlab CI/CD 中发布现有图像?

javascript - 将 $or 与 $elemMatch 和数组外部的条件一起使用