fix(shellEnv): 修复Windows环境下npx路径验证逻辑#1427
Conversation
- 修改测试用例描述,从shell执行改为通过npm入口点JS验证 - 添加fs模块模拟,确保existsSync方法返回预期值 - 在Windows环境下直接执行node.exe配合npx-cli.js路径进行版本检查 - 添加对node_modules/npm/bin目录下必要文件的存在性检查 - 当缺少npx.cmd或打包的npm脚本缺失时抛出错误 - 保持非Windows平台的原有验证逻辑不变
There was a problem hiding this comment.
💡 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".
| versionOutput = execFileSync(nodePath, [npxCliJs, '--version'], { | ||
| env, | ||
| encoding: 'utf-8', | ||
| timeout: 5000, | ||
| stdio: ['pipe', 'pipe', 'pipe'], |
There was a problem hiding this comment.
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 👍 / 👎.
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
Type of Change
Testing
Screenshots
Additional Context
Thank you for contributing to AionUi! 🎉