0
私はserver.js
(ここではappは明示的なインスタンス)に次のコードを持っています。これはserver.js
と同じディレクトリにあるindex.html
というファイルを返します。sendFileはエクスプレスベースのNodeアプリの関数ではありませんか?
app.get('/', function (req, res) {
var indexPath = path.resolve('index.html');
res.sendFile(indexPath);
});
ログアウトindexPath
これは私のhtmlファイルへの正しいパスです。しかし、私は次のエラー
TypeError: res.sendFile is not a function
を取得し、トレースを呼び出す:エクスプレス、senfile
、ないsendFile
にするために使用する方法の古いバージョンでは
at Object.handle (/Users/alexanderbollbach/Desktop/ABApp/server.js:54:9) at next_layer (/Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/route.js:103:13) at Route.dispatch (/Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/route.js:107:5) at /Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/index.js:195:24 at Function.proto.process_params (/Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/index.js:251:12) at next (/Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/index.js:189:19) at Layer.jsonParser [as handle] (/Users/alexanderbollbach/Desktop/ABApp/node_modules/body-parser/index.js:31:38) at trim_prefix (/Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/index.js:226:17) at /Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/index.js:198:9 at Function.proto.process_params (/Users/alexanderbollbach/Desktop/ABApp/node_modules/express/lib/router/index.js:251:12)
使用しているExpressのバージョンは何ですか? – elclanrs
私は使用しているバージョン^ 4 –
正確なバージョンは? 'sendFile'は4.8.0+でのみ利用可能です – elclanrs