简体   繁体   English

从Azure网站上的子文件夹托管的Node.js应用程序

[英]nodejs application hosted from sub-folder on azure websites

I'm hoping somebody can help me here. 我希望有人可以在这里帮助我。 I am very new to NodeJS and am trying to deploy a basic sample website created from the Angular seed project to an Azure website via git deploy. 我是NodeJS的新手,正在尝试通过git deploy将由Angular种子项目创建的基本示例网站部署到Azure网站。 The issue i'm having is that I don't understand how to configure the "root" of my application once it is deployed to Azure. 我遇到的问题是,将应用程序部署到Azure后,我不知道如何配置它的“根”。 My folder structure looks like this: 我的文件夹结构如下所示:

-app -app
--js --js
--css --css
--index.html --index.html
-scripts -scripts
--web_server.js --web_server.js

When I run locally, i just cd to my app folder and then start the web_server.js script with node from there. 当我在本地运行时,我仅需CD到我的应用程序文件夹,然后从此处启动带有节点的web_server.js脚本。

When it deploys to Azure, it somehow finds the web_server.js file and starts node. 部署到Azure时,它会以某种方式找到web_server.js文件并启动节点。 But now I have to browse specifically to the app subfolder to view my site. 但是现在我必须专门浏览到应用子文件夹才能查看我的网站。 I don't want to do that. 我不想那样做。 Any suggestions? 有什么建议么?

Look into using a package.json file in the root and pointing it to your site; 考虑在根目录中使用package.json文件并将其指向您的站点; use main or binaries to point to the subdirectory's JS file. 使用mainbinaries指向子目录的JS文件。

Azure Web Sites will use that information to find your scripts/web_server.js then, though it might be easier just to root it all at the top, at least to get things rolling. Azure网站将使用该信息来查找您的scripts/web_server.js ,尽管将其全部植根于顶部可能更容易,至少可以使事情顺利进行。

See also: https://www.npmjs.org/doc/files/package.json.html 另请参阅: https : //www.npmjs.org/doc/files/package.json.html

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

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