2
Node.jsとExpressでAngular 2アプリを作成しています。
私の問題は、ルートファイルがワイルドカードで動作しないということです。 ReferenceError: path is not defined
マイserver.js:Node.js/Expressがすべて2番のページにリダイレクト
const express = require('express');
const app = express();
const path = require('path');
const routes = require('./routes');
const data = require('./articles.json');
app.use(express.static(path.join(__dirname, '/dist')));
app.use('/', routes);
app.listen(8080, function() {
console.log('App started on port 8080');
});
マイ/routes/index.js:
const routes = require('express').Router();
routes.get('*', function (req, res) {
res.sendFile(path.join(__dirname + '/dist/index.html'));
});
module.exports = routes;
毎回私は、他のものとのページをご覧
/
(たとえば
/test
のために)それは次のように述べてい
ここで私は何が間違っていますか?
あなたのindex.jsにパスパッケージを必要とするように感謝を必要としています。私はすべてをルートファイルに移動しましたが、パスを忘れてしまいました。 Lol –
@LuudvanKeulenは私たちの最高の出来栄えです:-) – echonax
私は8分後にそれを受け入れます(SO Timerはすぐにそれを受け入れることはできません)。 –