easy-vps 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,25 @@ function compareVersions(a, b) {
44
44
  }
45
45
  return 0;
46
46
  }
47
+ /**
48
+ * Locate the npm CLI. The panel often runs as a systemd service whose `PATH`
49
+ * omits npm (especially under nvm), so `spawn('npm')` fails with ENOENT. npm
50
+ * always sits next to the Node binary, so derive it from `process.execPath`.
51
+ */
52
+ function resolveNpmCli() {
53
+ const nodeBin = node_path_1.default.dirname(process.execPath);
54
+ const candidates = [
55
+ node_path_1.default.join(nodeBin, 'npm-cli.js'),
56
+ node_path_1.default.join(nodeBin, 'npm'),
57
+ '/usr/local/bin/npm',
58
+ '/usr/bin/npm',
59
+ ];
60
+ for (const candidate of candidates) {
61
+ if ((0, node_fs_1.existsSync)(candidate))
62
+ return candidate;
63
+ }
64
+ return null;
65
+ }
47
66
  /** Fetch the latest published version; falls back to the current one offline. */
48
67
  async function checkForUpdate() {
49
68
  const { name, version } = readPackage();
@@ -75,7 +94,15 @@ function runUpdate(handlers) {
75
94
  // `--ignore-scripts` skips the package's postinstall, which would otherwise
76
95
  // try to start the panel itself and race with the running one. We restart
77
96
  // deliberately once the install finishes.
78
- const proc = (0, node_child_process_1.spawn)('npm', ['install', '-g', `${name}@latest`, '--ignore-scripts', '--no-audit', '--no-fund'], { stdio: ['ignore', 'pipe', 'pipe'] });
97
+ const npmCli = resolveNpmCli();
98
+ const installArgs = ['install', '-g', `${name}@latest`, '--ignore-scripts', '--no-audit', '--no-fund'];
99
+ // Run npm through Node directly so a missing `npm` on PATH doesn't matter.
100
+ const proc = npmCli
101
+ ? (0, node_child_process_1.spawn)(process.execPath, [npmCli, ...installArgs], {
102
+ stdio: ['ignore', 'pipe', 'pipe'],
103
+ env: { ...process.env, PATH: `${node_path_1.default.dirname(process.execPath)}:${process.env.PATH ?? ''}` },
104
+ })
105
+ : (0, node_child_process_1.spawn)('npm', installArgs, { stdio: ['ignore', 'pipe', 'pipe'] });
79
106
  const onData = (chunk) => {
80
107
  for (const line of chunk.toString().split('\n')) {
81
108
  if (line.trim())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-vps",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Install dependencies, point domains, deploy apps and run Postgres on a VPS from one UI",
5
5
  "keywords": [
6
6
  "vps",