GET net::ERR_ABORTED 404(未找到)

时间:2021-08-01 14:06:25

标签: javascript node.js express

我尝试导入两个模块,但在控制台中出现以下错误:

GET http://localhost:4444/scenes/World.js net::ERR_ABORTED 404 (Not Found)
game.js:3 
GET http://localhost:4444/node_modules/phaser/ 404 (Not Found)
game.js:1

我在我的路线中设置了路径(我使用的是 Express),但还没有奏效。 main.js

app.get("/World.js", isLoggedIn, function (req, res) {
  res.sendFile(path.join(__dirname, '/views/scenes', 'World.js'));
});

app.use("/node_modules", express.static('./phaser'));

app.get("/phaser", isLoggedIn, function (req, res) {
  res.sendFile(path.join(__dirname, '/', 'phaser'));
});

game.js

import { Phaser } from '../node_modules/phaser'

import Map from './scenes/World.js';

const config = {
    width: 800,
    height: 500,
    type: Phaser.AUTO
}

const game = new Phaser.Game(config)

game.scene.add('map', Map);

game.scene.start('map');

我能做什么?我看到了另一个问题,但没有人帮助我。

0 个答案:

没有答案
相关问题