Browse Source

fix(cli.js): fix invoking cli from a node shim, closes #5343 (#5345)

Amr Bashir 2 years ago
parent
commit
095b18620b
2 changed files with 6 additions and 1 deletions
  1. 5 0
      .changes/cli.js-node-shim.md
  2. 1 1
      tooling/cli/node/tauri.js

+ 5 - 0
.changes/cli.js-node-shim.md

@@ -0,0 +1,5 @@
+---
+"cli.js": patch
+---
+
+Fix crash when nodejs binary has the version in its name, for example `node18`

+ 1 - 1
tooling/cli/node/tauri.js

@@ -12,7 +12,7 @@ let binName
 
 // Even if started by a package manager, the binary will be NodeJS.
 // Some distribution still use "nodejs" as the binary name.
-if (binStem === 'node' || binStem === 'nodejs') {
+if (binStem.match(/(nodejs|node)([1-9]*)*$/g)) {
   const managerStem = process.env.npm_execpath
     ? path.parse(process.env.npm_execpath).name.toLowerCase()
     : null