Persistent “Cannot find module” errors when installing juggernaut in OS X and Rails 3

妖精的绣舞 提交于 2019-12-11 18:17:25

问题


I started with a blank install of Lion, installed Xcode 4.1, then followed the instructions at http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac to install rvm, sqlite3, rails and then installed node v0.2.5 and redis v2.0.4. I then tried to install juggernaut:

git clone git://github.com/maccman/juggernaut.git --recursive
cd juggernaut
sudo node server.js

After sudo node server.js I get the following error. I have somehow managed to get the same error on 2 separate computers, one with SL 10.6.6 and the other with Lion, clearly I am missing a step somewhere. Also 'optimist' is not the only module that is not found, many other variations of this error e.g cannot find module 'graceful-fs' etc. I have tried installing the modules manually. Please help with this problem.

fred:juggernaut fred$ sudo node server.js

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Cannot find module 'optimist'
    at Function._resolveFilename (module.js:317:11)
    at Function._load (module.js:262:25)
    at require (module.js:346:19)
    at Object.<anonymous> (/Users/fred/Desktop/redis-2.0.4/juggernaut/server.js:2:12)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at Array.<anonymous> (module.js:421:10)
    at EventEmitter._tickCallback (node.js:126:26)
fred:juggernaut fred$ 

回答1:


I may have had the same issue, or at least related. (Check out this SO question)

Your problem could be in your .bashrc or your .profile.

What does echo $PATH output? Depending on where your your node directory is located, it should output export PATH=$HOME/​local/node/bin:$PATH.




回答2:


I had the same problem under ubuntu 12.10 when I tried to run "nodejs server.js" after cloning the juggernaut git repo.

Eventually I installed juggernaut with npm ("npm install -g juggernaut") and now I can successfully run "nodejs /usr/local/lib/node_modules/juggernaut/server.js" (path may depend on your npm module installation).



来源:https://stackoverflow.com/questions/6843338/persistent-cannot-find-module-errors-when-installing-juggernaut-in-os-x-and-ra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!