Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在node/express应用程序的静态目录中呈现index.html_Javascript_Node.js_Express_Heroku - Fatal编程技术网

Javascript 在node/express应用程序的静态目录中呈现index.html

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

我在生产环境中的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.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'
我添加了另一个路径错误的实例。