index.js: (放在server文件夹中)。
const serve = require('koa-static')
const Koa = require('koa');
const app = new Koa();
app.use(serve(__dirname + './public'));
app.listen(3000);
console.log('listening on port 3000');我想显示index.html,它位于/public文件夹中。
当我在上面启动index.js时,我会在浏览器上看到Not Found。
console.log显示,它指的是index.js所在的同一个文件夹。
更新1:
console.log(__dirname + './public');显示
/Users/askar/work/react/hub/server./public,
但我需要/Users/askar/work/react/hub/public
发布于 2017-03-01 11:04:15
https://stackoverflow.com/questions/42526990
复制相似问题