gpt4 book ai didi

node.js - NodeJS 中的 Heroku 'cannot find module zlib'

转载 作者:太空宇宙 更新时间:2023-11-04 02:59:31 25 4
gpt4 key购买 nike

我认为这是我使用的 NodeJS 版本的问题,但我无法找到实际的问题和解决方案。这是heroku 日志:

 2012-08-11T19:25:48+00:00 heroku[web.1]: Starting process with command
`node app.js` 2012-08-11T19:25:49+00:00 app[web.1]:
2012-08-11T19:25:49+00:00 app[web.1]: node.js:134
2012-08-11T19:25:49+00:00 app[web.1]: throw e; //
process.nextTick error, or 'error' event on first tick
2012-08-11T19:25:49+00:00 app[web.1]: Error: Cannot find module 'zlib'
2012-08-11T19:25:49+00:00 app[web.1]: ^
2012-08-11T19:25:49+00:00 app[web.1]: at Function._load
(module.js:266:25) 2012-08-11T19:25:49+00:00 app[web.1]: at
Function._resolveFilename (module.js:320:11) 2012-08-11T19:25:49+00:00
app[web.1]: at require (module.js:348:19)
2012-08-11T19:25:49+00:00 app[web.1]: at Object.<anonymous>
(/app/node_modules/express/node_modules/connect/lib/middleware/compress.js:14:12)
2012-08-11T19:25:49+00:00 app[web.1]: at Module._compile
(module.js:404:26) 2012-08-11T19:25:49+00:00 app[web.1]: at
Module.load (module.js:336:31) 2012-08-11T19:25:49+00:00 app[web.1]:
at Object..js (module.js:410:10) 2012-08-11T19:25:49+00:00 app[web.1]:
at require (module.js:348:19) 2012-08-11T19:25:49+00:00 app[web.1]:
at Object.compress
(/app/node_modules/express/node_modules/connect/lib/connect.js:89:14)
2012-08-11T19:25:49+00:00 app[web.1]: at Function._load
(module.js:297:12) 2012-08-11T19:25:50+00:00 heroku[web.1]: Process
exited with status 1 2012-08-11T19:25:50+00:00 heroku[web.1]: State
changed from starting to crashed 2012-08-11T19:25:50+00:00
heroku[web.1]: State changed from crashed to starting
2012-08-11T19:25:52+00:00 heroku[web.1]: Starting process with command
`node app.js` 2012-08-11T19:25:53+00:00 app[web.1]:
2012-08-11T19:25:53+00:00 app[web.1]: node.js:134
2012-08-11T19:25:53+00:00 app[web.1]: throw e; //
process.nextTick error, or 'error' event on first tick
2012-08-11T19:25:53+00:00 app[web.1]: ^
2012-08-11T19:25:53+00:00 app[web.1]: Error: Cannot find module 'zlib'
2012-08-11T19:25:53+00:00 app[web.1]: at Function._resolveFilename
(module.js:320:11) 2012-08-11T19:25:53+00:00 app[web.1]: at
Function._load (module.js:266:25) 2012-08-11T19:25:53+00:00
app[web.1]: at require (module.js:348:19)
2012-08-11T19:25:53+00:00 app[web.1]: at Object.<anonymous>
(/app/node_modules/express/node_modules/connect/lib/middleware/compress.js:14:12)
2012-08-11T19:25:53+00:00 app[web.1]: at Module._compile
(module.js:404:26) 2012-08-11T19:25:53+00:00 app[web.1]: at
Object..js (module.js:410:10) 2012-08-11T19:25:53+00:00 app[web.1]:
at Module.load (module.js:336:31) 2012-08-11T19:25:53+00:00
app[web.1]: at Function._load (module.js:297:12)
2012-08-11T19:25:53+00:00 app[web.1]: at require
(module.js:348:19) 2012-08-11T19:25:53+00:00 app[web.1]: at
Object.compress
(/app/node_modules/express/node_modules/connect/lib/connect.js:89:14)

这是我的package.json:

{
"name": "App" , "version": "0.0.1" , "private": true , "dependencies": {
"express": "2.5.8"
, "jade": ">= 0.0.1" }
}

我的本​​地计算机上有 Node v0.6.13 并且正在使用它。我应该在 package.json 中声明 Node 版本吗?哪个版本可以缓解这个 zlib 问题?

最佳答案

我不知道 Heroku 上默认的 Node 版本是什么,但我认为它已经损坏了。我强制 Heroku 使用我正在使用的 Node.js 版本,它起作用了:

{
"name": "FriendButler"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.5.8"
, "jade": ">= 0.0.1"
}
, "engines": {
"node": "0.6.13",
"npm": "1.1.41"
}
}

关于node.js - NodeJS 中的 Heroku 'cannot find module zlib',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11917048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com