microsoft / vscode-generator-code

Visual Studio Code extension generator
Other
1.3k stars 224 forks source link

how to use "vscode" module in child_process #435

Closed NO-MAP closed 11 months ago

NO-MAP commented 1 year ago

I started a child_process in my extension process:

const { fork } = require('child_process');
const childProcess = fork(scriptPath);

In my child_process script, I required the vscode module:

const vscode = require('vscode');

const document = vscode.window.activeTextEditor?.document;

Then I encountered this error:

Cannot find module 'vscode'

I understand that vscode might be a special module. In the webpack.config.js file, the vscode module is marked as externals:

externals: ['vscode']

Is there any way to use the vscode module in my extension child_process?

aeschli commented 11 months ago

No, it's not a node module, but more like a global. It's only available in the extension host process.