Describe the bug
When running npm command from a script by using childProcess.execSync ~/.vite-plus/js_runtime/node/22.22.0/bin/npm is used instead of ~/.vite-plus/bin/npm, becuse ~/.vite-plus/js_runtime/node/22.22.0/bin is added before /home/ch4cha/.vite-plus/bin in the PATH. Is this expected behaviour? This is confusing as the output from npm --version command and childProcess.execSync("which npm", { cwd: projectDir, encoding: "utf-8", stdio: "pipe" }) differs.
Reproduction
Steps to reproduce
Given following package.json:
{
"name": "test",
"version": "1.0.0",
"type": "module",
"devEngines": {
"packageManager": {
"name": "npm",
"version": "11.17.0",
"onFail": "download"
},
"runtime": {
"name": "node",
"version": "22.22.0",
"onFail": "download"
}
}
}
we have:
npm --version
# 11.17.0
which npm
# ~/.vite-plus/bin/npm
which is expected.
Given index.js:
import childProcess from "node:child_process";
import path from "node:path";
const projectDir = path.resolve(import.meta.dirname, ".");
try {
const output = childProcess.execSync(`which npm`, {
cwd: projectDir,
encoding: "utf-8",
stdio: "pipe",
});
console.log(output);
} catch (error) {
console.error(String(error));
}
try {
const output = childProcess.execSync(`npm --version`, {
cwd: projectDir,
encoding: "utf-8",
stdio: "pipe",
});
console.log(output);
} catch (error) {
console.error(String(error));
}
node index.js output is:
~/.vite-plus/js_runtime/node/22.22.0/bin/npm
11.14.1
npm version reported from the script is 11.14.1 instead of 11.17.0. This is because ~/.vite-plus/js_runtime/node/22.22.0/bin/npm is used instead of ~/.vite-plus/bin/npm. Is this expected? I would assume running commands via the script would use the same env as regular commands in the same directory.
System Info
VITE+ - The Unified Toolchain for the Web
Environment:
Version 22.22.0
Source devEngines.runtime
Source Path ~/ps/test/package.json
Project Root ~/ps/test
Tool Paths:
node ~/.vite-plus/js_runtime/node/22.22.0/bin/node
npm ~/.vite-plus/js_runtime/node/22.22.0/bin/npm
npx ~/.vite-plus/js_runtime/node/22.22.0/bin/npx
Package Manager:
Name npm
Version 11.17.0
Source devEngines.packageManager
Source Path ~/ps/test/package.json
Project Root ~/ps/test
Bin Path ~/.vite-plus/package_manager/npm/11.17.0/npm/bin/npm
VITE+ - The Unified Toolchain for the Web
vp v0.2.1
Local vite-plus:
vite-plus Not found
Tools:
vite Not found
rolldown Not found
vitest Not found
oxfmt Not found
oxlint Not found
oxlint-tsgolint Not found
tsdown Not found
Environment:
Package manager npm v11.17.0
Node.js v22.22.0 (devEngines.runtime)
Used Package Manager
npm
Validations
Describe the bug
When running
npmcommand from a script by usingchildProcess.execSync~/.vite-plus/js_runtime/node/22.22.0/bin/npmis used instead of~/.vite-plus/bin/npm, becuse~/.vite-plus/js_runtime/node/22.22.0/binis added before/home/ch4cha/.vite-plus/binin thePATH. Is this expected behaviour? This is confusing as the output fromnpm --versioncommand andchildProcess.execSync("which npm", { cwd: projectDir, encoding: "utf-8", stdio: "pipe" })differs.Reproduction
Steps to reproduce
Given following
package.json:{ "name": "test", "version": "1.0.0", "type": "module", "devEngines": { "packageManager": { "name": "npm", "version": "11.17.0", "onFail": "download" }, "runtime": { "name": "node", "version": "22.22.0", "onFail": "download" } } }we have:
which is expected.
Given
index.js:node index.jsoutput is:npmversion reported from the script is11.14.1instead of11.17.0. This is because~/.vite-plus/js_runtime/node/22.22.0/bin/npmis used instead of~/.vite-plus/bin/npm. Is this expected? I would assume running commands via the script would use the same env as regular commands in the same directory.System Info
Used Package Manager
npm
Validations