推送拒绝,无法编译Node.js应用程序heroku

Pix*_*ded 11 git heroku node.js

当我试图将我的nodejs应用程序推送到heroku时git push heroku master,我得到了这个:

Counting objects: 975, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (862/862), done.
Writing objects: 100% (975/975), 3.74 MiB | 80.00 KiB/s, done.
Total 975 (delta 70), reused 0 (delta 0)

-----> Node.js app detected
-----> Resolving engine versions
   Using Node.js version: 0.10.15
   Using npm version: 1.3.3
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
   npm ERR! install Couldn't read dependencies
!     Push rejected, failed to compile Node.js app

To git@heroku.com:hidden-reaches-9268.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:hidden-reaches-9268.git'
Run Code Online (Sandbox Code Playgroud)

这是我的package.json:

{
  "name": "fnBoard",
  "version": "0.0.1",
  "private": true,
  "scripts": {
  "start": "node server.js"
},

  "dependencies": {
   "socket.io": "0.9.x"
},
   "engines": {
     "node": "0.10.x",
     "npm": "1.3.x"
   }
}
Run Code Online (Sandbox Code Playgroud)

里面有一堆错误,我不知道为什么会这样.请帮忙.-谢谢

Dan*_*ohn 10

最简单的方法是将node_modules添加到.gitignore.这里有更多信息:无法将node.js应用程序部署到heroku


Yog*_*rad 10

我在ReactJS工作,我正在尝试在Heroku服务器上部署我的项目.那时我发现了同样的错误:

推送被拒绝,无法编译Node.js应用程序.

在此输入图像描述

解决方案是:

如果你使用纱线:

git rm yarn.lock

git push heroku master

如果你使用npm:

git rm package-lock.json

git push heroku master

  • 并且不要忘记git commit -m"remove yarn/npm"在你推动之后和你之后 (6认同)
  • 这救了我的屁股。谢谢。 (2认同)

小智 6

添加 node_modules 可能很容易,但在这里不是正确的方法。相反git push -f heroku master,为了强制推送您的更新,告诉 heroku 覆盖任何预先存在的 node_modules。这样你的 git repo 就不会被节点库所困扰。