I installed the extension in the codespaces, and the extension is shown in the browser installed section. But when I use the command code --list-extensions, it didn't show the installed extension. I want to know why and how to show the extensions with commands. Thanks.
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'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.
How can I install multiple extensions in VSCode using the cli? I tried:
code --install-extension xyz.local-history jock.svg
but it only installs the first extension xyz.local-history.
Installing extensions...
Installing extension 'xyz.local-history' v1.7.0...
(node:10874) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Extension 'xyz.local-history' v1.7.0 was successfully installed.
If you are use Unix/Linux create a bash script with a loop. In this case I want to backup the extensions list and install again:
First create a list of the extensions:
$ code --list-extensions > extensions.txt
Create a bash script for example with the name vscode-extension-install.sh and input the following code:
#!/usr/bin/env bash
cat extensions.txt | while read extension || [[ -n $extension ]];
do
code --install-extension $extension --force
done
Then run:
$ ./vscode-extension-install.sh
Example output:
Installing extensions...
Installing extension 'visualstudioexptteam.vscodeintellicode' v1.2.6...
Extension 'visualstudioexptteam.vscodeintellicode' v1.2.6 was successfully installed.
Installing extensions...
Installing extension 'vscode-icons-team.vscode-icons' v10.0.0...
Extension 'vscode-icons-team.vscode-icons' v10.0.0 was successfully installed.
...
From my gists
Declare a variable, containing the name of all extensions you want to install... after you have it, you can iterate doing the installation one by one...
for extensions in ms-python.python ms-azure-devops.azure-pipelines ms-mssql.mssql
do code --install-extension $extensions
done
Maybe you also have to add your code.cmd path, but if your command is working typring code, this will be enough to do the taks
Happy coding!
If you are on Windows and do not use WSL, try a PowerShell loop.
Put all desired extensions in a text file (as in Linux example above) - say extensions.txt
Iterate over them with:
Get-Content extensions.txt | ForEach-Object {code --install-extension $_}
Note: this would work on every system supporting PowerShell
It's possible to pass the --install-extension argument multiple times and so install several extensions with just one line.
code --install-extension dbaeumer.vscode-eslint --install-extension esbenp.prettier-vscode
The documentation for this can be found in Extension Marketplace. Running this both extensions are installed but Installing extensions... is only found once in the output.
Disclaimer: This is not a command line approach, but rather a graphical way to install existing extensions on a new system using .vsix package, and might help some others with the same.
This method to install extensions on a new system (with reference to an existing system) requires Yeoman VS Code extension generator and vsce (or nodejs to install these).
On the existing machine, generate an extension pack (more details here)
npm install -g yo generator-code
yo code
First command installs Yeoman VS Code generator, second creates the extension pack (choose default options as below. The created package.json contains all extensions in the pack, you can modify that list)
On the existing machine, package the extension pack created above into a .vsix file
npm install -g vsce
vsce package
First command installs vsce, second packages the extension into a .vsix file (run from the root of the extension pack created above)
On the new system, install the .vsix file
code --install-extension extension-pack-0.0.1.vsix
Open VS Code on the new system, access this extension, install all required extensions via GUI
Might be useful to others.
I keep a dump of all extensions in text file for example:
code --install-extension aaron-bond.better-comments
code --install-extension abusaidm.html-snippets
code --install-extension afractal.node-essentials
code --install-extension anseki.vscode-color
code --install-extension be5invis.vscode-icontheme-nomo-dark
....
I would copy all contents of text file and then paste all the contents to PowerShell and then it would install plugins one by one.
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: