2016-03-31 14 views
0

私はExpressJSフレームワークを使用してNodeJSアプリケーションを構築しています。Nodejs:モンクを使用するとnpmの投げエラーが発生する

私はnpm startを行うとMongoDBの

var monk = require('monk'); 
var db = monk('localhost:3000/nodeauth'); 

に接続するために僧侶を使用しようとしている、私は次のエラー取得しています:

npm start 

> [email protected] start /home/bytegeek/Codes/Expressprojects/jsblog 
> node ./bin/www 

/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/utils.js:33 
    var skinClassName = 'Skin' + NativeClass.name; 
            ^

TypeError: Cannot read property 'name' of undefined 
    at makeSkinClass (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/utils.js:33:43) 
    at Object.<anonymous> (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/grid.js:6:35) 
at Module._compile (module.js:413:34) 
at Object.Module._extensions..js (module.js:422:10) 
at Module.load (module.js:357:32) 
at Function.Module._load (module.js:314:12) 
at Module.require (module.js:367:17) 
at require (internal/module.js:16:19) 
at Object.<anonymous> (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/db.js:22:16) 
at Module._compile (module.js:413:34) 
at Object.Module._extensions..js (module.js:422:10) 
at Module.load (module.js:357:32) 
at Function.Module._load (module.js:314:12) 
at Module.require (module.js:367:17) 
at require (internal/module.js:16:19) 
at Object.<anonymous> (/home/bytegeek/Codes/Expressprojects/jsblog/node_modules/mongoskin/lib/mongo_client.js:5:14) 

npm ERR! Linux 4.2.0-34-generic 
npm ERR! argv "/opt/node-v5.7.1-linux-x64/bin/node" "/opt/node-v5.7.1-linux-x64/bin/npm" "start" 
npm ERR! node v5.7.1 
npm ERR! npm v3.6.0 
npm ERR! code ELIFECYCLE 
npm ERR! [email protected] start: `node ./bin/www` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] start script 'node ./bin/www'. 
npm ERR! Make sure you have the latest version of node.js and npm installed. 
npm ERR! If you do, this is most likely a problem with the jsblog package, 
npm ERR! not with npm itself. 
npm ERR! Tell the author that this fails on your system: 
npm ERR!  node ./bin/www 
npm ERR! You can get information on how to open an issue for this project with: 
npm ERR!  npm bugs jsblog 
npm ERR! Or if that isn't available, you can get their info via: 
npm ERR!  npm owner ls jsblog 
npm ERR! There is likely additional logging output above. 

npm ERR! Please include the following file with any support request: 
npm ERR!  /home/bytegeek/Codes/Expressprojects/jsblog/npm-debug.log 

を私はすでにのMongoDBデータベースnodeauthを持ち、それにもいくつかの内容があります。 mongodサービスも実行されています。

P.S:私はコードの上記2行を削除し、npm startを行う場合は、エラーがないと私はそれが実行されているあなたのMongoDBポートを確認してくださいlocalhost:3000

答えて

0

で急行のウェルカムページを参照してくださいすることができますよ。あなたはデフォルトのポートを変更しなかった場合、それはhttp://localhost:27017/nodeauth

私は、あなたのアプリが3000ポートで実行されていると考えるべきです。したがって、mongodポートを確認し、再度確認してください。

+0

mongodbは27017で動作していますが、 'localhost:27017/nodeauth'は役に立ちませんでした。まだ同じエラーが表示されています。そして、はい、アプリは '3000'ポートで動作しています。 – byteseeker

0

monkモジュールのポート番号を省略します。このようにしてください。

var db = require('monk')('localhost/nodeauth'); 
関連する問題