防止在自定义 node.js 构建中创建控制台窗口 [英] Prevent console window from being created in custom node.js build

查看:31
本文介绍了防止在自定义 node.js 构建中创建控制台窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建 node.js 的自定义构建,它不应向用户显示控制台窗口.

I'm creating a custom build of node.js that should not show a console window to the user.

我尝试更改 gyp 文件中的 链接器配置2(应该设置链接器 flag /SUBSYSTEM:WINDOWS),但是当我运行生成的 node.exe 二进制文件时,我仍然看到一个控制台窗口.

I've tried changing the linker config in the gyp file to 2 (which should set the linker flag /SUBSYSTEM:WINDOWS), but I still get a console window when I run the resulting node.exe binary.

如何防止控制台窗口出现?

How can I prevent the console window from appearing?

进一步调查显示 node.gyp 中的链接器配置未生效.生成的node.vcxproj还有Console(这对我来说很奇怪,因为添加了'UACUIAccess': 'true' 在 node.gyp 的同一部分确实生效),因此构建的二进制文件链接不正确.

Further investigation reveals that the linker config in node.gyp is not taking effect. The generated node.vcxproj still has <Link><SubSystem>Console</SubSystem></Link> (which is very strange to me, since adding 'UACUIAccess': 'true' in the same part of node.gyp did take effect), so the built binary is incorrectly linked.

推荐答案

看来你必须:

  • Comment out the 'SubSystem': 1 line in common.gypi. (Changing it to 2 causes the build to fail in mksnapshot.)
  • Change SubSystem to 2 in node.gyp
  • Also add 'EntryPointSymbol': 'wmainCRTStartup' to node.gyp.

这会构建一个不创建控制台窗口的 node.exe.

This builds a node.exe that does not create a console window.

这篇关于防止在自定义 node.js 构建中创建控制台窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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