You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

nw.js打开双应用:"single-instance":false弃用后的实现方法

NW.js多应用/多实例启动解决方案

Hey there! Let's tackle your NW.js questions one by one, nice and clear:

1. 如何使用NW.js打开2个不同的应用

This is actually straightforward—if your two apps are separate (each has its own package.json and resources), you just need to launch them independently:

  • Open a terminal, navigate to the first app's root folder, and run nw . (make sure NW.js is in your system PATH, or use the full path to the NW executable if it's not).
  • Open another terminal window, head to the second app's root folder, and run nw . again.
    Boom, two separate NW.js apps will run side by side, completely independent of each other.

2. 当single-instance配置项被弃用时,如何启动同一个NW.js应用的多个实例

First, a quick clarification: the single-instance manifest option is indeed deprecated in NW.js. If your goal is to run multiple copies of the same app (not different apps), here are two solid workarounds:

方法1:启动时添加--multi-instance命令行参数

NW.js provides a command-line flag to force multi-instance behavior. Just add it when launching your app:

nw . --multi-instance

Run the same command again to spin up a second instance of the app. This flag overrides the default single-instance restriction.

方法2:在应用内部通过代码触发新实例

If you want to open a new instance from within the running app (like via a button click), use NW.js's App module to launch a new process:

const { App } = require('nw.gui');
const path = require('path');

// Example function to trigger when a button is clicked
function openNewAppInstance() {
  const appRoot = process.cwd();
  // Launch a new instance with the --multi-instance flag
  App.openFile(path.join(appRoot, 'package.json'), {
    args: ['--multi-instance']
  });
}

This lets you spawn a new copy of the same app directly from the existing one.

小补充

If you still just need to open different apps, you don't have to worry about the deprecated single-instance setting at all. NW.js treats apps with different name or uuid values (configured in package.json) as separate entities, so launching them individually works by default.

内容的提问来源于stack exchange,提问作者Eduard Arevshatyan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:28:50