简体   繁体   English

不包含node_modules文件夹时出现错误500

[英]Error 500 when not including the node_modules folder

LAST UPDATE 最后更新

It appeared that one my dependencies, not yet 1.0, changed its API between 2 versions. 似乎我的依赖项(不是1.0)在2个版本之间更改了其API。 My local version was outdated, and when pushing to Heroku, Heroku downloaded the latest version, with the API change that crashed my app. 我的本地版本已过时,当推送到Heroku时,Heroku下载了最新版本,并且API更改导致我的应用崩溃。

CONCLUSION : When using libraries not stable yet (that didn't reach 1.0), stick to a specific version. 结论 :当使用库还不稳定(即没有达到1.0),坚持一个特定版本。

Thank you guys for trying to help me. 谢谢你们帮助我。

================= =================

Using Node 0.8.latest, express 3.latest. 使用Node 0.8.latest表示3.latest。

One of my route works perfectly locally, but gives me a 500 error when the app is deployed. 我的一条路线在本地运行完美,但是在部署该应用程序时出现500错误。 The error message is very app-specific, but illogic. 该错误消息是非常特定于应用程序的,但不符合逻辑。 It's a TypeError, telling me that something (that should be defined) is undefined. 这是一个TypeError,告诉我某些东西(应定义)未定义。 To make it work, the only weird solution I found was to remove node_modules from .gitignore and tracking it under git. 为了使它起作用,我发现的唯一奇怪的解决方案是从.gitignore中删除node_modules并在git下跟踪它。 When pushed on heroku, no error appears and the url just works 当在heroku上推送时,没有错误出现,并且该URL可以正常工作

It starts to get strange when you know that I DID NOT change any code inside of the node_modules folder. 它开始变得陌生,当你知道,我并没有改变node_modules文件夹内的任何代码。 I also compared locally and "heroku"ly installed dependencies by comparing a local npm ls to the list of modules produced when pushing to heroku, since it rebuilds the dependencies because they're .gitignore 'd. 我还通过将本地npm ls与推送到heroku时生成的模块列表进行比较,比较了本地和“ heroku”安装的依赖项,因为它重建了依赖项,因为它们是.gitignore I see minor but inexplicable differences on a few packages noted invalid with npm ls . 我看到一些软件包的微小但无法解释的差异,在npm ls认为是invalid None of this package is in my package.json file, they're dependencies for my package in package.json . 这个包都不在我的package.json文件中,它们是我的包在package.json依赖项。 Namely, connect is 2.4.4 locally and 2.5.0 on heroku, send is 0.0.4 locally and 0.1.0 on heroku, emitter-compnonent is 0.0.1 locally and 0.0.5 on heroku. 即, connect在本地为2.4.4,在heroku为2.5.0, send在本地为0.0.4,在heroku为0.1.0, emitter-compnonent在本地为0.0.1,在heroku为0.0.5。 The rest is striclty identical. 其余部分完全相同。

The other thing to note is that the error stacktrace points a module which has identical versions on both environments and which doesn't depend on nor isn't a dependency for the modules that have different versions. 还要注意的另一点是,错误stacktrace指向一个模块,该模块在两种环境下具有相同的版本,并且不依赖于也不依赖于具有不同版本的模块。 So even the minor dependency differences shouldn't be the cause of the problem. 因此,即使是很小的依赖性差异也不应成为问题的原因。

But then, I can't see where does the problem come from, and I would like to avoid tracking my node_modules files. 不过,我看不出来自哪里的问题,我想避免跟踪我node_modules文件。 Or should I ? 还是我应该?

UPDATE 更新

Here's my package.json file as per request by Hector Correa 这是我根据赫克托·科雷亚(Hector Correa)的要求发出的package.json文件

{
  "name": "myapp",
  "version": "0.1.0",
  "dependencies": {
    "express": "3.0.x",
    "mongoose": "3.0.x",
    "superagent": "0.9.x",
    "oauth": "0.9.x",
    "querystring": "0.1.x",
    "consolidate": "~0.4.0",
    "mustache": "~0.6.0",
    "singly": "*",
    "underscore": "~1.4.1"
  },
  "devDependencies": {
    "mocha": "1.4.x",
    "supertest": "0.1.x"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

Below is working example package.json in Heroku 以下是Heroku中的工作示例package.json

{
    "name": "MyApp"
    , "version": "0.0.1"
    , "dependencies": {
          "express": "3.x.x"
    }
    , "devDependencies": {
        "mocha": "*"
        , "should": "*"
        , "supervisor": "*"
        , "superagent": "*"
        , "request": "*"
    }
    , "engines": {
        "node": "0.8.x"
        , "npm": "1.1.x"
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM