Javascript 在node/express应用程序的静态目录中呈现index.html
我在生产环境中的react/node/express应用程序中出现渲染Javascript 在node/express应用程序的静态目录中呈现index.html,javascript,node.js,express,heroku,Javascript,Node.js,Express,Heroku,我在生产环境中的react/node/express应用程序中出现渲染index.html问题。我的应用程序文件结构是: -项目 --应用程序 ---距离 ----index.html ----main.js ----style.css --服务器 ---js看起来您正在使用的路径被弄乱了: app.use(express.static(path.join(__dirname, "../app/dist"))); app.get('/',function(req,res){ res.se
index.html
问题。我的应用程序文件结构是:
-项目
--应用程序
---距离
----index.html
----main.js
----style.css
--服务器
---js
看起来您正在使用的路径被弄乱了:
app.use(express.static(path.join(__dirname, "../app/dist")));
app.get('/',function(req,res){
res.sendFile(path.join(__dirname,"../app/dist/index.html"));
});
尝试将这些值更改为:
path.join(__dirname, "./dist")
path.join(__dirname,"./dist/index.html")
看起来您正在使用的路径被弄乱了:
app.use(express.static(path.join(__dirname, "../app/dist")));
app.get('/',function(req,res){
res.sendFile(path.join(__dirname,"../app/dist/index.html"));
});
尝试将这些值更改为:
path.join(__dirname, "./dist")
path.join(__dirname,"./dist/index.html")
错误消息应该可以帮助您找到正确的方向:
error:enoint:没有这样的文件或目录,stat'/app/app/dist/index.html'
在您的server.js文件中,尝试使用res.sendFile(path.join(\uu dirname+'/app/app/dist/index.html')
错误消息应该可以帮助您找到正确的方向:错误:enoint:没有这样的文件或目录,stat'/app/app/dist/index.html'
在您的server.js文件中,尝试使用res.sendFile(path.join(\uu dirname+'/app/app/dist/index.html')代码>感谢回复@wex。不幸的是,它仍然返回错误:enoint:没有这样的文件或目录,stat'/app/app/dist/index.html'
我添加了另一个路径错误的实例。感谢回复@wex。不幸的是,它仍然返回错误:enoint:没有这样的文件或目录,stat'/app/app/dist/index.html'
我添加了另一个路径错误的实例。