Sub topic 5
Installing the Salesforce Extension Pack
This chapter assumes you have already installed VS Code, the Salesforce CLI (sf), and a Java JDK, as covered in the earlier chapters. It also assumes you are comfortable running commands in a terminal. Here you add the extensions that turn VS Code into an Apex editor.
What the pack contains
The Salesforce Extension Pack is a bundle. Installing it installs several extensions at once, so you do not have to find each one by hand. The extensions you will use most in this tutorial are:
- Salesforce CLI Integration, which adds the
SFDX:commands to the Command Palette and wraps thesfCLI. - Apex, which provides code completion, navigation, and diagnostics through the Apex language server. The language server is a Java program, which is why the JDK matters.
- Apex Replay Debugger, which steps through debug logs. A later chapter covers it.
- Apex Interactive Debugger and Visualforce, Lightning Web Components, and Aura Components support, which this tutorial does not use directly.
The extensions do not replace the CLI. They call it. If sf is missing from your PATH, most commands in the extensions will fail.
Install from the Extensions view
- Open VS Code.
- Open the Extensions view with
Ctrl+Shift+X(Cmd+Shift+Xon macOS). - Search for
Salesforce Extension Pack. - Select the result published by Salesforce and click Install.
- Reload the window if VS Code asks you to.
Check the publisher name before you install. Other extensions have similar names.
Install from the terminal
You can also install the pack with the code command. The extension ID is salesforce.salesforcedx-vscode.
code --install-extension salesforce.salesforcedx-vscode
code --list-extensions | grep salesforceThe second command lists installed extensions whose IDs contain salesforce. On Windows PowerShell, use Select-String salesforce in place of grep salesforce. You should see several entries, such as salesforce.salesforcedx-vscode-apex and salesforce.salesforcedx-vscode-core.
Use the terminal route on machines you set up often, or when you script a workstation setup.
Verify the installation
The extensions activate only when VS Code opens a folder that contains an sfdx-project.json file. You create that file in the next chapter. Until then, you can still confirm that the commands exist.
- Open the Command Palette with
Ctrl+Shift+P(Cmd+Shift+Pon macOS). - Type
SFDX:. - Confirm that a list of commands appears, such as
SFDX: Create ProjectandSFDX: Authorize an Org.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| No `SFDX:` commands appear | Extension not installed or window not reloaded | Reinstall, then reload the window |
| `code` is not recognized in the terminal | The `code` command is not on your PATH | On macOS, run `Shell Command: Install 'code' command in PATH` from the Command Palette |
| Apex features never start | Java is missing or the wrong version | Revisit the JDK chapter and set `salesforcedx-vscode-apex.java.home` |
| Commands fail with "sf not found" | CLI is not on the PATH VS Code sees | Restart VS Code after installing the CLI |
Checkpoint
At this point you should have the pack installed, SFDX: commands visible, and the three tool checks passing from the first chapter:
code --version
sf --version
java -versionExercise
You installed the Salesforce Extension Pack, but the Apex features such as code completion do not work, and the SFDX: commands do appear in the Command Palette. Which dependency should you check first, and why?
Show answer
Check the Java JDK. The Apex extension runs the Apex language server, which is a Java program. If Java is missing or the extension cannot find it, the SFDX: commands can still work, because they depend on the CLI, but code completion and navigation will not. Confirm java -version works, then set salesforcedx-vscode-apex.java.home if needed.