NodeWebkit-部署应用程序 [英] NodeWebkit - deploy the application

查看:121
本文介绍了NodeWebkit-部署应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对Web和NodeWebkit(NW)应用程序的代码库. 我使用以下堆栈: -反应 -哈皮 -续集 -Windows环境

I have one code base for both Web and NodeWebkit (NW) application. I use the following stack: - React - Hapi - Sequelize - Windows environment

该应用程序的Web版本使用MySQL,而NW使用Sqlite.一切正常.我有一个配置文件,可以根据我的需要(Web或NW)来编译应用程序.

Web version of the application uses MySQL, while NW uses Sqlite. It all works fine. I have config file that compiles application for what I need (web or NW).

我现在面临的问题是如何部署NW应用程序.想法是向客户提供NW应用程序,然后单击该图标,客户将打开该应用程序.

The problem that I face now is how to deploy the NW application. Idea is to provide NW applicaiton to a client, where he will open it clicking the icon.

由于我将节点用于NW版本,并且该应用程序使用存储在node_modules中的许多模块,因此我面临如何打包所有模块的挑战.

Since I use the Node for the NW version, and the application uses many modules which are stored in node_modules, I face a challenge how to pack it all up.

我的想法是制作一个Windows安装程序.用户将单击它,安装程序会将所有文件提取到目标位置.并在用户桌面上制作一个图标来运行它.

My idea is to make an Windows installer. User will click it and the installer will extract all files to the destination. And also make an icon on the user desktop to run it.

问题在于Windows文件名限制.在node_modules内部,有许多子目录完全违反Windows限制.我什至不能复制node_modules文件夹.我什至不能删除它.很好,如果我将其压缩,可以复制它...或手动删除长文件夹.

Problem is with the Windows file name limitation. Inside the node_modules, there are many subdirectories that simply violate the Windows limitation. I cant even copy the node_modules folder. I cant even delete it. Well sure I can copy it If I zip it... or remove manually long folders.

我尚未开始使用安装程序,但是我想我会用这种方法来解决问题.

I have not yet started working on the installer, but I am thinking I will hit the wall with this approach.

有人知道如何进行此部署吗? 如何集成 NPM3 在NW?

Does anyone have an idea how to make this deployment? How can I integrate NPM3 in NW?

我现在的计划是制作Windows安装程序. Windows安装程序将正常安装应用程序文件. node_modules将预先压缩并放置在安装程序中.然后,安装程序将其简单地解压缩到目标文件夹中.

My plan now is to make Windows installer. That windows installer will install normally application files. The node_modules will be zipped previously and placed inside the installer. Installer will then simply unzip it to the destionation folder.

我将在这里发布进度.

此处有一些更新. 这里的主要问题是node_modules的深度.我在node_modules中有很多模块,经过一番思考,我发现那里有一条简单的规则.一些模块是服务器端模块,而其他模块则由react使用. 而且由于Webpack已经创建了一个巨大的文件,其中已经包含了所有模块,所以我根本不需要它们.

Some update here. Main issue here was the depth of the node_modules. I have many modules in node_modules, and after some thinking I figured out there is a simple rule there. Some modules are server side modules, while other ones are used by react. And since Webpack already creates a huge files in which all of the modules are already included, I simply do not need them at all.

因此,我删除了所有前端侧模块(babel模块,react- *),只保留了服务器端(Hapi,sequelize ...).奇迹发生了,应用程序运行了,并且启动时快得多.

So I have removed all front end side modules(babel modules, react-*), and left only server side (Hapi, sequelize...). Miracle happened, application run and was much faster at the startup.

我将使用Inno设置来创建清单文件,并且应该很好.

I am going to use Inno setup to make a manifest file, and it should be good to go.

我仍然没有走出危险区域,因为开发人员可能需要一个服务器端模块,该模块具有很大的深度.但是,如果发生的话,我会考虑的.

I am still not out of the danger zone, as developer might need a server side module, which has huge depth. But I will think about that if it happens.

更多需要关注的内容...

More to follow...

推荐答案

实际上,在nodejs中,您可以执行以下操作:

actually in nodejs you can do the following:

1-在项目文件夹中创建另一个文件夹,例如"server_modules"

1-Create another folder inside your project folder for example "server_modules"

2-在创建的文件夹中创建另一个package.json文件,并在那里安装服务器所需的所有模块

2-In the created folder create another package.json file and install any modules needed for server out there

3-所有这些模块都可以使用require('module_name')作为普通的node_modules进行访问,如果不需要,可以在打包桌面版本时删除"server_modules"文件夹

3-All these modules will be accessible as normal node_modules using require('module_name') and you can delete "server_modules" folder when you package your desktop version if you don't need it

注意:某些开发人员使用这种方法在Node.js中实现微服务,但在您的情况下很有用

Note: this approach used by some developers to achive micro services in nodejs but it is useful in your case

这篇关于NodeWebkit-部署应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆