次のコマンドを実行してNPMを使用して接続モジュールをインストールしました。
npm install connect
/ Download / usr / node_modules/connectフォルダーにモジュールを作成しました。接続モジュールを使用するファイルを作成しました
var connect = require('connect');
var util = require('util');
function sendjson(res,obj)
{
res.writeHead(200,{'Content-Type':'application/json',});
var objstr = JSON.stringify(obj);
util.debug('SENDJSON' + objstr);
res.end(objstr);
}
var server = connect.createServer(
connect.router(function(app){
app.get('/foo', function(req,res){
sendjson(res,{path:'foo'});
})
app.get('/bar', function(req,res){
sendjson(res,{path:'bar'});
})
})
);
server.listen(3000);
ノードcreateServer.jsを実行すると、ターミナルがスローされ、次のエラーが発生します。
モジュール「接続」が見つかりません