Skip to content

Commit 5209336

Browse files
committed
execPath test
1 parent f03f068 commit 5209336

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ jobs:
9393

9494
- run: corepack enable
9595

96+
- name: Show resolved npm via execPath
97+
run: |
98+
node -e 'import { dirname, join } from "node:path";
99+
import { execPath } from "node:process";
100+
import { spawnSync } from "node:child_process";
101+
const npmBin = join(dirname(execPath), "npm");
102+
console.log("Resolved npm:", npmBin);
103+
const res = spawnSync(npmBin, ["--version"], { stdio: "inherit" });
104+
process.exit(res.status);'
105+
96106
- name: Find and export npm path
97107
run: |
98108
which npm || echo "npm not found"

lib_dev/process.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -251,33 +251,7 @@ export function setup(cwd = process.cwd()) {
251251
* @param {ExecOptions} [options]
252252
* @return {Promise<ExecResult>}
253253
*/
254-
async npm(args = [], options = {}) {
255-
// First try to use NPM_PATH from environment (set by CI)
256-
if (process.env.NPM_PATH) {
257-
try {
258-
await fs.access(process.env.NPM_PATH);
259-
console.log(`Using npm from NPM_PATH: ${process.env.NPM_PATH}`);
260-
return exec(process.env.NPM_PATH, args, options);
261-
} catch (err) {
262-
console.log(`npm at NPM_PATH not accessible: ${err.message}`);
263-
}
264-
}
265-
266-
// Try to find npm in the same directory as node
267-
const nodePath = process.execPath;
268-
const nodeDir = path.dirname(nodePath);
269-
const npmPath = path.join(nodeDir, "npm");
270-
271-
try {
272-
await fs.access(npmPath);
273-
console.log(`Using npm from Node.js directory: ${npmPath}`);
274-
return exec(npmPath, args, options);
275-
} catch (err) {
276-
console.log(`npm not found in Node.js directory: ${err.message}`);
277-
}
278-
279-
// Final fallback to direct npm execution
280-
console.log("Falling back to direct npm execution");
254+
npm(args = [], options = {}) {
281255
return exec("npm", args, options);
282256
},
283257
};

0 commit comments

Comments
 (0)