File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 11import fs from "node:fs" ;
2+ import module from "node:module" ;
23import path from "node:path" ;
34import { fileURLToPath } from "node:url" ;
45
@@ -21,16 +22,23 @@ export default function getExePath() {
2122 else {
2223 // We're actually running from an installed package.
2324 const platformPackageName = "@typescript/" + expectedPackage ;
24- let packageJson ;
2525 try {
26- // v20.6.0, v18.19.0
27- packageJson = import . meta. resolve ( platformPackageName + "/package.json" ) ;
26+ if ( typeof import . meta. resolve === "undefined" ) {
27+ // v16.20.1
28+ const require = module . createRequire ( import . meta. url ) ;
29+ const packageJson = require . resolve ( platformPackageName + "/package.json" ) ;
30+ exeDir = path . join ( path . dirname ( packageJson ) , "lib" ) ;
31+ }
32+ else {
33+ // v20.6.0, v18.19.0
34+ const packageJson = import . meta. resolve ( platformPackageName + "/package.json" ) ;
35+ const packageJsonPath = fileURLToPath ( packageJson ) ;
36+ exeDir = path . join ( path . dirname ( packageJsonPath ) , "lib" ) ;
37+ }
2838 }
2939 catch ( e ) {
3040 throw new Error ( "Unable to resolve " + platformPackageName + ". Either your platform is unsupported, or you are missing the package on disk." ) ;
3141 }
32- const packageJsonPath = fileURLToPath ( packageJson ) ;
33- exeDir = path . join ( path . dirname ( packageJsonPath ) , "lib" ) ;
3442 }
3543
3644 const exe = path . join ( exeDir , "tsgo" + ( process . platform === "win32" ? ".exe" : "" ) ) ;
Original file line number Diff line number Diff line change 2727 "type" : " module" ,
2828 "preferUnplugged" : true ,
2929 "engines" : {
30- "node" : " >=20.6 .0"
30+ "node" : " >=16.20 .0"
3131 },
3232 "bin" : {
3333 "tsgo" : " ./bin/tsgo.js"
You can’t perform that action at this time.
0 commit comments