嘿家伙,我知道之前有人问过,但我不明白,所以任何人都请帮忙

const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 3000;
const api = require('./server/routes/api');
const path = require('path');

app.use(express.static(path.join(__dirname, 'dist/todo')));

app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

app.use('/api', api);

app.get('*', (req, res) => {
    res.sendFile(path.join(__dirname, 'dist/todo/index.html'));
})

app.listen(port, () => console.log('server started'));

启动服务器时出现的错误

throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))