Windows: Node execFile/execFileSync cannot run global lark-cli (.cmd shim)

Open
#2,826 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript, node.js, powershell
Domain
cli, documentation

Research direction

Start with the bin entry in package.json and the entry script at scripts/run.js, then check the README for any existing install or usage notes. Confirm the reported Windows behaviour by running the .cmd shim versus node scripts/run.js with execFileSync. Done means a short "Programmatic usage" section that shows the node …/scripts/run.js invocation for Windows without shell: true, pending maintainer agreement on whether an install-layout change is also wanted.

Written by the indexing model from the issue text.

Description

domain/core

Summary

On Windows, after a normal npm global install of @larksuite/cli, calling:

import { execFileSync } from 'node:child_process'
execFileSync('lark-cli', ['--profile', '…', 'docs', '+fetch', /* … */], {
  encoding: 'utf8',
  stdio: ['ignore', 'pipe', 'pipe'],
})

fails, while the same command works when typed in PowerShell/cmd.

This affects programmatic / Agent callers that intentionally use execFile (no shell) to keep argv unescaped and avoid shell injection.

Environment

  • OS: Windows 10/11
  • Package: @larksuite/cli (reproduced on 1.0.97)
  • Install: npm global (lark-cli on PATH)
  • Node: 22+ / 24.x

What npm installs on Windows

Global bin typically creates:

  • lark-cli.cmd
  • lark-cli.ps1
  • real entry: node_modules/@larksuite/cli/scripts/run.js (package.json bin: { lark-cli: scripts/run.js }`)

The .cmd shim ultimately runs:

node ...\node_modules\@larksuite\cli\scripts\run.js %*

PowerShell/cmd resolve lark-cli to that shim, so interactive use works.
Node execFile / execFileSync does not run .cmd without shell: true, so looking up the bare command name lark-cli fails in Agent/tooling code.

Workaround (works today)

Spawn the Node entry directly (no shell):

execFileSync(process.execPath, [
  String.raw`C:\path\to\node_global\node_modules\@larksuite\cli\scripts\run.js`,
  '--profile', profile,
  'docs', '+fetch',
  '--doc', url,
  '--as', 'user',
  '--format', 'json',
], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] })

(or resolve run.js from PATH’s */node_modules/@larksuite/cli/scripts/run.js)

Using shell: true also “works” but is undesirable for untrusted/argv-sensitive automation.

Request

  1. Document the recommended Windows programmatic invocation (node …/scripts/run.js …) for humans and AI Agents that must avoid shell: true.
  2. Optionally consider a Windows-friendly install story for non-shell spawners (e.g. document PATH layout, or ship/clarify a non-.cmd entry if feasible). Understanding this is partly an npm-on-Windows convention; even a short “Programmatic usage” note would unblock Agent integrations.

Not asking for

  • Changing Feishu OpenAPI auth or docs APIs — this is only about the CLI process entrypoint on Windows.

Thanks!

Dominant language
Go
Stars
18.2k
Forks
1.4k
Avg merge
1d 3h
Merged PRs (30d)
18

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from larksuite/cli

All issues in larksuite/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.