Error adding own extension to theia

Publish your extension to npm and add your own package to dependencies in the package.json file. But there is an error in the browser console, theia has been loading


Where can I go wrong?

@Xotm thank you for the discussion, the error occurs when your application is using a mismatch of @theia versions which is not allowed.

If you execute yarn why @theia/core you’ll probably see multiple versions of core being used and how they are being pulled.

I saw the relevant information on your m


ethod, so what should I do next?

@Xotm it looks like you’re using next which can be problematic, better to use a specific version like 1.27.0 (which your duplicate @theia/core is already using). You can’t mismatch versions so the only way forward is making sure they all use the same version of @theia deps.

Your method has been successful, thank you very much. How can I avoid similar problems when I publish my own extensions in the future. I generated the code through the official Theia Extension Yeoman generator

When publishing the extension alone, it is probably best to specify the range of supported versions, or ^1.27.0 if you do not foresee any incompatibility in the near future (1.27.0 is fine when you want to support only this version).
On the other hand, for building an application, you’d better stick with a particular version or theia (hence vince’s good advice). For this purpose, I suggest using Selective dependency resolutions | Yarn in your application’s package.json

This way, your extension can be published with a large compatibility range, and you control which version exactly your application is using. You can inspect the changes on yarn.lock file manually to check the impact of your modifications. Whenever you see your yarn.lock file has changed, it’s best to wonder why and check that it really does what you want.