I have authored a VSCode extension vscode-typer that auto-magically live types code. Great for development demonstrations.
Problem is, while it works in development mode (I have the extension open in VSCode and I use run extension to bring up a test VSCode), however, if I use vsce to make a VSIX file, and then install said VSIX extension, when attempting to use my extension I see the following error: command 'extension.devFestResetMain' not found
I feel like I am missing a magic incantation somewhere...
Reproduction steps: vscode-typer/issues/1
Turns out I was confusing development time dependencies for run time dependencies.
Related
I am developing an extension for VS Code. This extension is already good enough for me to use during daily work, but not good enough to be published (yet). Is there a canonical way to make an unpublished extension under development available to VS Code? Optimally, I would like to always have the current state of the code running.
I did find a way that seems to work, but I'm not sure whether this is a terrible hack or okay: Create a symbolic link in VS Code's extensions directory (~/.vscode/extensions on Linux) to the development directory. Is there a better/official way?
You can package your extension (even if it's in development) using vsce with the command vsce package. This will create a .vsix file which you can install in your regular instance of VSCode in the marketplace menu (click on the ... icon at the top and select "Install from .vsix file).
If you need to view the logs of the extension, go to Help>Toggle Developer tools and use the console to view your extension's output (if there is any).
I would like to install some dependencies when im installing my custom extension for VSCode. It might also be preferable to run a piece of code when i first install this extension in VSCode. Where do i write that code??
I have Prettier extension installed in my VS Code. Up until the last update everything worked fine, and now I am prompted with this question:
The Prettier extension will use 'node_modules/prettier/index.js' for
validation, which is installed locally in folder 'my_project_folder'.
Do you allow the execution of the Prettier version including all
plugins and configuration files it will load on your behalf?
Press 'Allow Everywhere' to remember the choice for all workspaces.
If I decline it, the Prettier formatting will not work.
Why am I prompted with this since I have Prettier installed as an Extension and not as npm package?
it is the VS Code extension and not some npm package?
The opposite is true. Prettier is not a VS Code extension. The extension is a bridge (integration) between your editor and the Prettier package installed in the project. In different projects, different versions of Prettier are installed, so to make sure all the collaborators get the same formatting, the local version must always be used. On the other hand, running code from node_modules in VS Code is a certain security risk (e.g., think of a malicious fork of Prettier), so the extension makes the user aware of that. You didn't see this prompt before because it has been added recently.
I'm building a custom VS Code extension to some stuff. Basically, I'm relying on a few npm packages to get the job done.
But I would to like to do something like vscode-eslint extension does: if user have eslint package installed, it will use the local package instead the bundled one.
Basically I want to do this behavior:
Would this be possible with VSCode?
PS: I tried to study vscode eslint extension, but I was not able to understand how it handles this situation.
I am not able to download any extension via VS Code on my office system due to the proxy. Is there a way that I can do it manually by downloading and placing the downloaded files at the right place?
Download the extension from VSCode marketplace, it'll be a .vsix file, then do like the image below.
You can also use the command-line to install extensions from VSIX files using the --install-extension parameter.
code --install-extension /path/to/vsix
eg: code --install-extension vscodevim.vim
Just in case u have a same UI as mine. Happy coding!
You can also just drop the extension files into the correct folder. On mac, for example, this is ~/.vscode/extensions/. I'm unsure whether it works for all extensions, but it works just fine for a simple language specification.
Two notes when downloading an extension from VScode marketplace:
Version compatibility
Extensions are updated repeatedly on the marketplace. If you download and transfer it to the target computer, it may not work. One can try to look into version history of the extension and download the older version. But it is not easy to correlate the extension version with VSCode version. You can check the version of the extension on the online computer and try to find a match in the marketplace. But sometimes the older versions are not listed there.
Dependencies
An extension may have dependencies. When installing from within VSCode, VScode installs the dependencies for you. Good example is the Python extension that requires few other extension like Jupyter and pylance.
To handle these two cases easier:
1- Install the same VSCode version on the online (access to internet) computer as the offline (no access to internet) target computer.
2- From within the VSCode, install the desired extension. It will install the right version and all the dependencies.
3- Find the folder where extensions are installed. On windows, it is in: C:\Users\USER_NAME\.vscode\extensions. On Linux, it is ib ~/.vscode/extensions.
4- Copy and transfer the extensions to the target offline computer, in the extensions folder.
5- Restart the VSCode to see the extensions.
The below screenshot shows all the extensions that I transferred to have the python extension available on the target computer: