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

Windows系统Bash环境下如何无需额外模块并行运行多个npm脚本?

Windows Bash环境下无弹窗并行运行npm脚本的解决方案

以下是无需额外安装npm模块的几种实现方式:

  • 子shell后台运行
    将需要后台执行的命令包裹在子shell中并后台运行,既不会弹出新窗口,也能保证两个脚本并行执行:

    "start": "(npm run server &) && npm run client"
    

    若需要两个脚本都在后台运行,可改为:

    "start": "(npm run server &) && (npm run client &)"
    
  • nohup 配合后台运行
    利用nohup让命令脱离终端运行,同时重定向输出避免生成冗余日志文件,全程无弹窗:

    "start": "nohup npm run server > /dev/null 2>&1 & npm run client"
    

    若需两个脚本都后台执行:

    "start": "nohup npm run server > /dev/null 2>&1 & nohup npm run client > /dev/null 2>&1 &"
    
  • 强制使用Bash解析命令
    若VSCode终端的Bash对&解析异常,可显式调用bash -c来执行命令组合,确保后台运算符生效:

    "start": "bash -c 'npm run server & npm run client'"
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 12:55:15