File tree Expand file tree Collapse file tree
src/server/typingsInstaller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace ts . server . typingsInstaller {
44 const fs : {
5- appendFileSync ( file : string , content : string ) : void
5+ appendFileSync ( file : string , content : string ) : void ;
6+ existsSync ( path : string ) : boolean ;
67 } = require ( "fs" ) ;
78
89 const path : {
@@ -32,11 +33,12 @@ namespace ts.server.typingsInstaller {
3233 /** Used if `--npmLocation` is not passed. */
3334 function getDefaultNPMLocation ( processName : string ) {
3435 if ( path . basename ( processName ) . indexOf ( "node" ) === 0 ) {
35- return `"${ path . join ( path . dirname ( process . argv [ 0 ] ) , "npm" ) } "` ;
36- }
37- else {
38- return "npm" ;
36+ const npmPath = `"${ path . join ( path . dirname ( process . argv [ 0 ] ) , "npm" ) } "` ;
37+ if ( fs . existsSync ( npmPath ) ) {
38+ return npmPath ;
39+ }
3940 }
41+ return "npm" ;
4042 }
4143
4244 interface TypesRegistryFile {
You can’t perform that action at this time.
0 commit comments