简体   繁体   中英

Unable to use VSCode CLI from extension

I am trying to create an extension and want to use 'code --version' inside child_process, but always it is return version of 'node'. from commandline I was able to use code --version without any issue.

Code:-

var output = child.spawnSync("code",['--version']);
vscode.window.showInformationMessage(`${output.stdout}.`)

One thing I have noticed is always 'code' is considered as 'node' with in child process. Could someone help me to identify the cause of this issue.

Thank You. Chaithanya

Found that the process is running under VSCode installation folder which have code.exe. After changing code to below lines, it started working as expected.

const bat = child.execSync('bin\\code --list-extensions');
console.error(bat.toString());

Thank You.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM