LWC - Salesforce

Software Setup (VS Code, Extensions, SFDX)


Objective

A. Installing the Visual Studio Code
B. Installing the Salesforce Extension
C. Installing the Salesforce CLI

In this unit, we will be installing the required software/plugins to develop lightning web components.


How to set up visual studio code for Salesforce?

A. Installing the Visual Studio Code

Visual Studio Code is a lightweight code editor from Microsoft. It comes with built-in support for JavaScript, TypeScript and Node.js and is available for Windows, MacOS and Linux.

This is an IDE to develop better in salesforce. Salesforce is supporting all the new stuff for the vs code plugins(extensions).

Step #1: Download Visual Code Studio

The installation of Visual Studio Code depends on your platform.
Goto the official website of Microsoft to install the VS Code.

https://visualstudio.microsoft.com/downloads/


VS Code Download


Here click on the Free Download button and it will ask you to save the files. Unzip the files after downloading and install the vs code.

MaCOS

If your platform is MacOS, the installation is very easy. Download the Visual Studio Code archive, double click to unpack the archive and drag the file Visual Studio Code.app to the Applications folder.

Windows

If you’re on Windows, you need to download and run the installer (VSCodeSetup-stable.exe). Having completed the installation successfully you can find Visual Studio Code in C:\Program Files (x86)\Microsoft VS Code.

Linux

The installation of Visual Studio Code under Linux depends on the distribution you’re using. For a distribution-specifc installation guides take a look at https://code.visualstudio.com/docs/setup/linux

You must install the vs code v1.26 or later. If you have already installed the vs code. Please check the version of your vs code. Sometimes vs code’s standard check updates does not work. In this case, You can uninstall the older version and install it from the beginning. I faced the issues while working on this.


Step #2: After downloading open the Visual code studio you will see something like these.


VS Code Open File



B. Installing the Salesforce Extension

Step #3: Click on the symbol Extension shown in the below image.


VS Code Extension


Step #4:  Type Salesforce extension pack in search box and click install as shown in below image.


Salesforce Extension Package


C. Installing the Salesforce CLI

CLI stands for Command Line Interface. Salesforce CLI provides a lot of commands to make your life easy. You can create different environments for development, testing, individual orgs fro team and merging the code in a single org using the scratch orgs and version control.


Step #5: Open google chrome and search for install Salesforce cli and open the link as shown in below image.


Salesforce CLI Download


Step #6: Click download in the below image.


Salesforce CLI Download


I highly recommend you to follow the steps from salesforce’s official document. click here.


Step #7: To check if it is downloaded properly open Command Prompt and type sfdx --version and press enter.


Command Prompt for SFDX


Now to install the latest plugin type sfdx plugins:install [email protected] and wait till the installation is completed.

Run this command in your terminal (Mac) or CMD (Windows).

sfdx plugins:install [email protected]


Command Prompt for SFDX


Step #8: Now we need to set the path and environment variable on our system.

Add to the PATH on Windows 10

• Open the Start Search, type in “env”, and choose “Edit the system environment variables”:

• Click the “Environment Variables…” button.


Environment-SetUp-Windows10


• Double click on Path and check if the Path has the C:\Program Files\Salesforce CLI\bin. Also the under the System variable check if the Path has C:\Program Files\Salesforce CLI\bin. If this is missing under Path in User variables for home or System variables section create the same using the new button.


Environment-SetUp-Windows10


Step #9: Now to check if everything is setup properly go to Visual Studio and Press CTRL+SHIFT+P.

Enter SFDX: Create Project with Manifest -> Enter the project name -> Select the folder. It will create a Project for us after running as shown below.


Environment-SetUp-Windows10


 MIND IT !

If you get this error: Error: Salesforce CLI is not installed

Just close the visual code studio and start again.