不做解释,代码一看就懂

app.js

import express from 'express'
import config from './config' const app = express() app.use('/node_modules', express.static(config.node_modules_path))
app.use('/public', express.static(config.public_path)) app.set('views', config.viewPath)
app.set('view engine', 'ejs') app.get('/', (req, res) => {
res.render('index')
}) app.listen(3000, () => {
console.log('server is running at port 3000...')
})

config.js

import { join } from 'path'

export default {
viewPath: join(__dirname, '../views'),
node_modules_path: join(__dirname, '../node_modules'),
public_path: join(__dirname, '../public')
}
05-13 23:19