Search code examples
visual-studio-codevscode-extensions

My LSP extension doesn't work when installed from the Marketplace


I've created a LSP extension for VSCode that doesn't get installed properly from the Marketplace. I found out it doesn't install some node_modules (but it installs others).

In case it's needed, the missing modules are:

  • vscode-html-languageservice
  • vscode-languageserver-textdocument
  • vscode-nls
  • vscode-uri

This the error I get:

Activating extension 'publisher.name' failed: Cannot find module 'vscode-html-languageservice'
Require stack:
c:\Users\****\.vscode\extensions\publisher.name-0.1.0\client\out\extension.js
c:\Program Files\Microsoft VS Code\resources\app\out\vs\loader.js
c:\Program Files\Microsoft VS Code\resources\app\out\bootstrap-amd.js
c:\Program Files\Microsoft VS Code\resources\app\out\bootstrap-fork.js.

All other modules (like vscode-languageclient) are correctly installed.

I checked that if I copy those folders manually (or if I run npm i), then the extension works.

Also, and even more confusing to me, when I package the extension the .vsix file has all the missing dependencies. And if I install it then the extension works. But when I upload the working .vsix file directly to the marketplace manager it doesn't work either.

It's like the marketplace deletes those modules for some reason? I didn't find any explanation here or in the docs.

This is my .vscodeignore file (but the same happens even if I leave it blank)

.vscode
**/*.ts
**/*.map
out/**
node_modules/**
client/src/**
client/out/**
server/src/**
server/out/**
tsconfig.json
webpack.config.js
.gitignore

FYI, the missing modules are inside client/node_modules.

As you can see, I'm using webpack, but if I don't bundle it it's the same.

I've read similar posts here, like this one: VSCode extension cannot find module when installed from Marketplace, but those solutions doesn't work for me:

  • I just type vsce publish in my terminal (the only scripts related are "vscode:prepublish": "npm run compile", "compile": "tsc -b",)
  • vsce is updated
  • Modules are in the package.json file (I even deleted node_modules and reinstalled them)
  • Without bundling the .vsix file is 1,62 MB, so it's not a size issue
  • vsce ls includes the modules

Anyone has any idea what I'm missing?

Thanks.

Edit 1: Downloading the .vsix file from the Marketplace has all the node modules.


Solution

  • I couldn't find a solution to my issue, but looks like a caching problem. A workaround I found is to change my extension name. I had no issues after that.