导入 expressEdge 后,我被卡住了。
const path =require('path');
const expressEdge = require('express-edge');
const express = require('express');
const app = new express();
app.use(express.static('public'));
app.use(expressEdge);
app.set("views", `${__dirname}/views`);
app.get('/', (req, res) => {
res.render('index')
})
app.get('/about.html', (req, res) => {
res.sendFile(path.resolve(__dirname, 'pages/about.html'));
})
app.get('/contact.html', (req, res) => {
res.sendFile(path.resolve(__dirname, 'pages/contact.html'));
})
app.get('/post', (req, res) => {
res.sendFile(path.resolve(__dirname, 'pages/post.html'));
})
app.listen(5000, () => {
console.log('App listening o port 5000');
})
在尝试介绍 expressEdge 时,出现以下错误:
at Object.<anonymous> (C:\Users\Globalwise\Desktop\nodejs-blog\index.js:11:5)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
[nodemon] 应用程序崩溃 - 启动前等待文件更改...
您的帮助将不胜感激。
提前谢谢大家。