Follow these steps to get set up for local App Scripts development.
-
Install Node.js and npm: If you haven't already, you'll need Node.js and npm on your machine.
# macOS or Linux brew install node # Windows choco install nodejs
-
Install Clasp: Use npm to install the clasp CLI tool globally.
npm install -g @google/clasp
-
Initialize Clasp: Inside your project directory, initialize clasp to link it with your Google Apps Script project.
clasp clone <scriptId> # if you're starting with an existing Apps Script project # OR clasp create "Your Project Name" # to create a new Apps Script project
-
Generate
credentials.json
: Visit the Google Cloud Console, create a new project, enable the Google Apps Script API, and download yourcredentials.json
file. -
Clasp Login: Run the following command and point clasp to your
credentials.json
to log in.clasp login --creds ./path/to/credentials.json
-
Set OAuth Scopes: In your
appsscript.json
file, define the OAuth scopes that your project needs.{ "oauthScopes": [ "https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive" // ... other scopes ] }
-
Develop Locally: Write your Apps Script code (
.gs
files) using your preferred IDE, in this case, VS Code. -
Push Changes: Use
clasp push
to upload your local code to the Apps Script project.clasp push
-
Run Function: Run your Apps Script function locally via the clasp CLI.
clasp run "YourFunctionName"
- View Logs: To check the output or any logs, you can use
clasp logs
, or navigate to the Logs section in the Google Apps Script Editor or Google Cloud Logging.
And that's the setlist! Now you're tuned up and ready to jam. Let me know if you hit any sour notes or if you're ready for the encore! 🎶