前奏
今天下午准备部署自己写的Meteor 一个web应用,然而这个一部署就折磨我半天的时间
过程
下午一点多提交了最后一个commit准备去服务器写脚本部署了,脚本很快写完,但是部署时遇到一个 很大的问题,就是报:
Error: Module did not self-register.
itodoPro-9 (err): at Error (native)
itodoPro-9 (err): at Module.load (module.js:355:32)
itodoPro-9 (err): at Function.Module._load (module.js:310:12)
itodoPro-9 (err): at Module.require (module.js:365:17)
itodoPro-9 (err): at require (module.js:384:17)
itodoPro-9 (err): at bindings (/home/strucoder/personal/itodoPro/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
itodoPro-9 (err): at Object.<anonymous> (/home/strucoder/personal/itodoPro/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:3:35)
itodoPro-9 (err): at Module._compile (module.js:460:26)
itodoPro-9 (err): at Object.Module._extensions..js (module.js:478:10)
itodoPro-9 (err): at Module.load (module.js:355:32)
当时有点茫然,遇到自己代码写的错误还有头绪解决,遇到这样的问题,基本没辙了,去google一番,万万没想到啊
我的vpn这个关键点居然重连不上了,经过漫长的等待,终于vpn连上了,这里不得不感慨,我们这些人,没有互联网没有
vpn如何存活下去。
像我这样的问题node上也有相似的issues, 这也是比较蛋疼的,
node 0.12还是这么肯爹。然而iojs是支持的,看到这个,我也是醉了。。。
最终的stackoverflow上找到了和我一样的提问,解决方法是:
rm -R path/to/bcrypt
npm install bcrypt
这里要说明的是这个bcrypt是Meteor账户系统一个核心的package,不能缺少。 但是这里问题虽然解决了,还有一个需要面临的问题,安装bcrypt需要sudo,但是pm2不能用sudo执行, 不然很有可能会报:
events.js:85
throw er; // Unhandled 'error' event
^
Error: connect EACCES
at exports._errnoException (util.js:746:11)
at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1000:19)
如果出现这个,基本你的pm2就没有用了,需要彻底删除重装,当然我在下面的链接也给出了 老外的解决方法,有些繁琐 出现这个问题的原因就是:
For UNIX domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path
prefix.
参考来自这里
当然这个老外也给出了解决办法,我没看,觉得没这么繁琐,我直接:
- uninstall pm2
- cd .npm && sudo rm -rf pm2*
- cd ~ && sudo rm -rf .pm2
- sudo npm install pm2 -g
就这样简单粗暴的解决了,我也给这个issues写出了我的答案
所以在这些问题和不稳定的因素下我决定暂时先等着, 当然也有好的解决办法,退回node v0.10* 不过这不是我的风格。 先完善自己的Meteor 应用。
结局
一个字: 先等着 耽误我吃午饭的时间,让我准备今天冲个澡的心情都没了。
最后
本分享允许以*.itodo.me和*.cnodejs.org域名进行分享交流, 转载请注明链接来源。 原文:itodo.me Thanks :)
咳咳。。。。。。为什么我觉得你这里遇到的问题单纯是因为从 0.10 升级到 0.12 之后,node_modules 没有重新安装导致的…
第一个 bcrypt 的问题,我好像遇到过,就是因为 bcrypt 用到了 c++ addon,所以 0.10 的编译的包不能直接在 0.12 使用。 然后我再看 pm2 这个问题的解决方案,也是重装啊。而且 pm2 也用到了 c++ addon。
楼上正解,升级大版本的node,那些包最好重新安装一遍。
@alsotang 嗯,问题的本质确实是这样,Meteor自带的是0.10版本的pkg, 所以在0.12上报了错 对于pm2重装解决不了,因为在我这个情况下不是管理员权限,连pm2 list都报错。只能rm 后重装
@xieren58 确实这样,但是有些包的安装需要sudo 这也很容易导致pm2 只能一管理员的身份运行。;)
@struCoder 我用 nvm 安装 node,从来就没见过什么包一定要 sudo。。。设好 $PATH 就行了
@alsotang 是的,但meteor打包后的文件都是加锁的,我在他里面删文件都要sudo,重新安装 当然需要sudo。
建议部署环境的nodejs版本跟meteor自带的nodejs版本一致
@booxood 我还是再等等吧,同时完善一下自己的应用,退回又要重新编译,哈哈,偷懒。。。
是的,我升级0.12后启动nodeclub也是报错的。 不过我就简单地运行 npm uninstall bcrypt,再npm install bcrypt就解决了,哈哈
@alsotang @struCoder **I am using node 0.12.6. After fixing some errors, and update the modules there are still problems existing, And I have tried the solutions listed above, but all of them don’t work for my case. I have searched on the google, but cannot find the solution yet. It should be related to the version violate problem. But any other ways to fix them? BTW, my OS is Ubuntu 14.04 LTS. Thank you in advance!
Error log is following:
/nodeclub/node_modules/bcrypt/node_modules/bindings/bindings.js:83
throw e
^
Error: Module did not self-register.
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at bindings (/home/federer/nodeclub/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/home/federer/nodeclub/node_modules/bcrypt/bcrypt.js:3:35)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/federer/nodeclub/common/tools.js:1:76)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/federer/nodeclub/models/base_model.js:5:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/federer/nodeclub/models/user.js:2:17)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/federer/nodeclub/models/index.js:14:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/federer/nodeclub/app.js:22:1) at Module._compile (module.js:460:26)
at Object.Module._extensions…js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
and I change to downgrade to use node v0.10.40. After reinstalling missing modules, node app.js is applicable. And then it runs! log prints: Nodeclub listening on port 3000 God bless love… You can debug your app with http://localhost:3000 When vising http://localhost:3000, the interfaces for Nodeclub shows. But error log again, show blow. I think it should also be related to version violation problem, but how to fix it? Thank you in advance!
http.js:852
throw new TypeError(‘first argument must be a string or Buffer’);
^
TypeError: first argument must be a string or Buffer
at ServerResponse.OutgoingMessage.write (http.js:852:11)
at ServerResponse.OutgoingMessage.end (http.js:982:16)
at /home/federer/nodeclub/node_modules/loader/lib/loader.js:90:13
at /home/federer/nodeclub/node_modules/less/lib/less/render.js:35:17
at /home/federer/nodeclub/node_modules/less/lib/less/parse.js:63:17
at Object.finish [as _finish] (/home/federer/nodeclub/node_modules/less/lib/less/parser/parser.js:183:28)
at Object.ImportVisitor._onSequencerEmpty (/home/federer/nodeclub/node_modules/less/lib/less/visitors/import-visitor.js:35:14)
at ImportSequencer.tryRun (/home/federer/nodeclub/node_modules/less/lib/less/visitors/import-sequencer.js:50:14)
at Object.ImportVisitor.run (/home/federer/nodeclub/node_modules/less/lib/less/visitors/import-visitor.js:29:25)
at Object.Parser.parse (/home/federer/nodeclub/node_modules/less/lib/less/parser/parser.js:189:22)
at Object.parse (/home/federer/nodeclub/node_modules/less/lib/less/parse.js:61:18)
at Object.render (/home/federer/nodeclub/node_modules/less/lib/less/render.js:25:18)
at /home/federer/nodeclub/node_modules/loader/lib/loader.js:83:12
at fs.js:272:14
at Object.oncomplete (fs.js:108:15)
when running the command line: make test What It listed are just warnings, but no error details for both 0.12.6 and 0.10.40: ¨¨¨¨ warning… make:*** [test] Error 1
alsotang ,Thank you! Your solution works on 0.10.40: sudo rm node_moduels -r npm install … node app.js Then everything seems OK. NodeClub listening on port 3000 God bless love… You can debug your app with http://localhost:3000
Started 2015-09-02T06:14:02.497Z GET / 127.0.0.1 Cache set {“deleted”:false}pages 0ms MONGO topics.find {“conditions”:{“deleted”:false,“tab”:{"$ne":“job”},“reply_count”:0},“options”:{“limit”:5,“sort”:{“create_at”:-1},“fields”:{}},“collectionName”:“topics”} 65ms Cache set no_reply_topics 0ms MONGO topics.find {“conditions”:{“deleted”:false},“options”:{“skip”:0,“limit”:20,“sort”:{“top”:-1,“last_reply_at”:-1},“fields”:{}},“collectionName”:“topics”} 71ms MONGO users.find {“conditions”:{“is_block”:false},“options”:{“limit”:10,“sort”:{“score”:-1}},“collectionName”:“users”} 74ms Cache set tops 0ms Render view index (88ms) Completed 200 (188ms)
Started 2015-09-02T06:14:03.105Z GET /favicon.ico 127.0.0.1 Completed 404 (9ms)
And local host can be visited properly! But the solution doesn’t work on 0.12.06 yet. Problems still exist on 0.12.06. But it confirms that it is a version violation issue. I will take a look at this in the future by myself. Thank you for you anwser!
@federerlee dont need to sync message from github to here.