Skip to content

Commit 4f6dfdd

Browse files
committed
What is one more hack at this point?
1 parent b70a3a6 commit 4f6dfdd

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ jobs:
9191
cache: yarn
9292
node-version-file: .nvmrc
9393

94+
- name: Find and export npm path
95+
run: |
96+
NPM_PATH=$(which npm)
97+
echo "NPM_PATH=$NPM_PATH" >> $GITHUB_ENV
98+
echo "Found npm at: $NPM_PATH"
99+
npm --version
100+
94101
- name: Install npm packages
95102
run: yarn install
96103

lib_dev/process.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,32 @@ export function setup(cwd = process.cwd()) {
252252
* @return {Promise<ExecResult>}
253253
*/
254254
async npm(args = [], options = {}) {
255-
// Use node to run npm directly since npm might not be in PATH
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
256267
const nodePath = process.execPath;
257268
const nodeDir = path.dirname(nodePath);
258269
const npmPath = path.join(nodeDir, "npm");
259270

260271
try {
261-
// Try to use npm from the same directory as node
262272
await fs.access(npmPath);
263273
console.log(`Using npm from Node.js directory: ${npmPath}`);
264274
return exec(npmPath, args, options);
265275
} catch (err) {
266276
console.log(`npm not found in Node.js directory: ${err.message}`);
267277
}
268278

269-
// Fallback to direct npm execution
279+
// Final fallback to direct npm execution
280+
console.log("Falling back to direct npm execution");
270281
return exec("npm", args, options);
271282
},
272283
};

0 commit comments

Comments
 (0)