javascript - 没有这样的文件或目录,stat 'C:\idora-photobok\backend\frontend\build\index.html'
问题描述
因此,在尝试准备我的应用程序进行生产时出现此错误。所以,我的 index.js 代码是
const app = express();
const port = 8000;
const cors = require('cors');
const db=require('./config/mongoose');
const path = require('path')
//library used
const passport = require('passport');
const passportJWT = require('./config/passport-jwt-strategy');
const bcrypt = require('bcrypt');
//middleware
app.use(express.json());
app.use(cors());
//use routes
app.use('/', require('./routes'));
app.use(express.static(path.join(__dirname, '/frontend/build')))
app.get('*', (req, res) =>
res.sendFile(path.join(__dirname, 'frontend', 'build', 'index.html')))
app.listen(port, async function(err){
if(err){
console.log(`error in running of server;${err}`);
}
console.log(`server is running on port:${port}`);
});
这是我的文件结构。所以,如果有人知道,为什么会这样。请回复。
谢谢
解决方案
推荐阅读
- php - 解析图像网址(来自服务器)并将其存储到内部存储中的有效方法?
- ios - 如何将评论从 UIViewController 发送到另一个 UIViewController 并将它们存储在数组中?
- php - 查找与类别无关的产品
- android - 从 Google Play 商店安装应用程序后仅显示卸载按钮
- javascript - socket.io 和异步事件
- python - 是否有用于创建不带括号的 python 元组的 lint 规则?
- java - 如何在 Java 11 中获取 POSIX 文件描述符?
- sql - 如何为同一行中的相同参考ID获取两个不同的值
- sql - 如果有任何其他内容按原样放置,请从字段中删除前导零。绑定变量未声明
- python - Python,如何将函数作为参数传递给类方法