简体   繁体   English

PM2在浏览器中未显示Express应用

[英]PM2 not showing Express app in browser

I am using PM2 in my Express app for process management and load balancing. 我在Express应用程序中使用PM2进行流程管理和负载平衡。 I have just installed the PM2 and given the command pm2 start bin/www this command works in command prompt, it is showing the result like this: 我刚刚安装了PM2,并给了命令pm2 start bin/www该命令在命令提示符下有效,它显示的结果如下:

3]

This is fine now I am opening the web browser and accessing the application as usual localhost:3000 but it is not opening the application its is showing ok in the browser. 这很好,现在我打开Web浏览器并像往常一样localhost:3000访问该应用程序,但是它没有打开该应用程序,它在浏览器中显示正常

What could be the possible reason? 可能是什么原因? Please help. 请帮忙。 Thanks. 谢谢。

I got the solution. 我找到了解决方案。 We know when we create an app using Express (Express generator) it creates all the folder and places app.js file in the root folder. 我们知道,当我们使用Express(Express生成器)创建应用程序时,它将创建所有文件夹并将app.js文件放置在根文件夹中。 For some reason, I kept the app.js file inside a folder and changed its path in bin/www file. 由于某种原因,我将app.js文件保留在一个文件夹中,并在bin/www文件中更改了其路径。 It was working perfectly when I was running npm start but with PM2 it was now opening the application in the browser. 当我运行npm start ,它运行良好,但是使用PM2时,它正在浏览器中打开应用程序。 So I again placed the app.js file in the root folder and now it is working fine. 所以我再次将app.js文件放在根文件夹中,现在它可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM