インストールNodeJSのv0.6.12一切方法「ルータのエラーを持っていません。のMac OS X NodeJS:Macのポートを使用して、MAC OS X上
win764:node iwaldman$ which node
/opt/local/bin/node
win764:node iwaldman$ node -v
v0.6.12
npm install connectを使用してインストール済みの接続。
var connect = require('connect');
var util = require('util');
function sendJSON(response, obj) {
response.writeHead(200, {'Content-Type':'application/json'});
var objStr = JSON.stringify(obj);
util.debug('SENDJSON: ' + objStr);
response.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, {parth: 'bar'});
})
})
);
server.listen(3000);
util.debug('Server running at http://127.0.0.1:3000');
実行ノードconnectServer.js:
は簡単なプログラム、connectServer.jsを書きました。任意のアイデアが高く評価されている
win764:node iwaldman$ node connectserver.js
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Object function createServer() {
function app(req, res){ app.handle(req, res); }
utils.merge(app, proto);
utils.merge(app, EventEmitter.prototype);
app.route = '/';
app.stack = [].slice.apply(arguments);
return app;
} has no method 'router'
at Object.<anonymous> (/Users/iwaldman/dev/node/connectserver.js:12:10)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
:
は、次のエラーを取得します。
あなたは接続と読書速達チュートリアルを使用していますか? 'connect.router'は事ではありません。どちらも 'app.get'ではありません – loganfsmyth
私はチュートリアルを通して自分の道を進んでいます。私はExpressを使用していません。 –
チュートリアルは何ですか?たぶん古いですね? – loganfsmyth