I’m developing a VSCode extension (package.json) and I get the "Error: Cannot find module ‘vscode’" whenever I run it.
I’ve already tried running
npm install
and it did not help.
When I run
node ./node_modules/vscode/bin/install
I get "Error installing vscode.d.ts: Missing VSCode engine declaration in package.json.".
3
Answers
Remove the "vscode" dev dependency. No idea what that is for.
Your
package.json
is out of date, and is still using a deprecated definition. This has been changed, if I remember correctly, a couple of years ago.You should update your dependency to something like
And don’t forget to update the
engines
entry as well, to reflect the minimun VS Code version your extension will support.Hope this helps
I’m not sure what it is yet, and I’ll be back if I figure it out, but I’m assuming this is expecting to be run in VS Code, and I’m not doing that. I’m trying to create an LSP client outside of VS Code, and I think thats the rub.