Skip to content

fix(shellEnv): 修复Windows环境下npx路径验证逻辑#1427

Merged
kaizhou-lab merged 1 commit intoiOfficeAI:mainfrom
JAVA-LW:codex/fix_windows_npx
Mar 19, 2026
Merged

fix(shellEnv): 修复Windows环境下npx路径验证逻辑#1427
kaizhou-lab merged 1 commit intoiOfficeAI:mainfrom
JAVA-LW:codex/fix_windows_npx

Conversation

@JAVA-LW
Copy link
Copy Markdown
Contributor

@JAVA-LW JAVA-LW commented Mar 19, 2026

  • 修改测试用例描述,从shell执行改为通过npm入口点JS验证
  • 添加fs模块模拟,确保existsSync方法返回预期值
  • 在Windows环境下直接执行node.exe配合npx-cli.js路径进行版本检查
  • 添加对node_modules/npm/bin目录下必要文件的存在性检查
  • 当缺少npx.cmd或打包的npm脚本缺失时抛出错误
  • 保持非Windows平台的原有验证逻辑不变

Pull Request

Description

报错:
codex ACP process exited during startup (code: 1):
node:internal/modules/cjs/loader:1451
throw err;
^

Error: Cannot find module 'D:\Code\ChatGPT_team_web\current_version\node_modules\npm\bin\npm-prefix.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1448:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
at Module._load (node:internal/modules/cjs/loader:1234:25)
at TracingChannel.traceSync (node:diagnostics_channel:328:14

w err;
^

Error: Cannot find module 'D:\Code\ChatGPT_team_web\current_version\node_modules\npm\bin\npm-prefix.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1448:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
at Module._load (node:internal/modules/cjs/loader:1234:25)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
at node:internal/main/run_main_module:33:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v24.13.1
node:internal/modules/cjs/loader:1451
throw err;
^

Error: Cannot find module 'D:\Code\ChatGPT_team_web\current_version\node_modules\npm\bin\npx-cli.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1448:15)
at defaultResolveImpl (node:internal/modules/cjs/loader:1059:19)
at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1064:22)
at Module._load (node:internal/modules/cjs/loader:1234:25)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:154:5)
at node:internal/main/run_main_module:33:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Node.js v24.13.1

Related Issues

#1376

  • Closes #

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • Tested on macOS
  • Tested on Windows
  • Tested on Linux
  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • My changes generate no new warnings or errors

Screenshots

Additional Context


Thank you for contributing to AionUi! 🎉

- 修改测试用例描述,从shell执行改为通过npm入口点JS验证
- 添加fs模块模拟,确保existsSync方法返回预期值
- 在Windows环境下直接执行node.exe配合npx-cli.js路径进行版本检查
- 添加对node_modules/npm/bin目录下必要文件的存在性检查
- 当缺少npx.cmd或打包的npm脚本缺失时抛出错误
- 保持非Windows平台的原有验证逻辑不变
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa48be09ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +449 to +453
versionOutput = execFileSync(nodePath, [npxCliJs, '--version'], {
env,
encoding: 'utf-8',
timeout: 5000,
stdio: ['pipe', 'pipe', 'pipe'],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Probe the same Windows npx wrapper you later execute

On Windows the returned command is still npx.cmd, but this probe now bypasses the wrapper and runs the sibling npx-cli.js directly. The stock npx.cmd first calls npm-prefix.js and may redirect to %PREFIX%\node_modules\npm\bin\npx-cli.js, so machines with a stale/broken global npm install can pass this check and then still fail when the app actually spawns npx.cmd. In other words, this no longer validates the binary resolveNpxPath() returns, so the Windows startup regression remains for users whose wrapper redirects away from the bundled scripts.

Useful? React with 👍 / 👎.

@kaizhou-lab kaizhou-lab merged commit 82dd74b into iOfficeAI:main Mar 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants