Nibesh Khadka
Khadka's Coding Lounge

Khadka's Coding Lounge

How to Write Google Apps Script Code Locally In Your Favorite IDE?

How to Write Google Apps Script Code Locally In Your Favorite IDE?

An easy step-by-step guide

Nibesh Khadka's photo
Nibesh Khadka
·Aug 8, 2022·

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Table of contents

  • Install Clasp
  • Set-Up Project Locally
  • Clone the Project from Cloud to Local
  • How to push to the cloud?
  • Prepping To Push To Git Repo
  • Conclusion

Take apps script ID from your project and set up a local Dev Environment with Clasp.

Install Clasp

I'll be using Linux for this project but if you're using windows then omit the sudo command, to install the clasp package.

sudo npm install -g @google/clasp

# For windows
# npm install -g @google/clasp

I'm assuming that you have already installed node, npm, and VS code.

Check the installation result with:

clasp -v

Set-Up Project Locally

Please pick your favorite folder to set up a local project for our apps script project ( You don't have to do it)

npm init

After that let's create a new folder that will clone the app scripts project. Let's call it src(source).

# Inside the project folder
mkdir src

Clone the Project from Cloud to Local

Now, we'll clone the project from the apps script dashboard to vs code. To do that App Script ID is needed. You can find the ID in Projects Settings> IDs(check out the image below).

App Script ID Location

Copy the ID then, on the terminal clone the project.

clasp clone "ID inside quote" --rootDir src

Here,

  1. We are providing id inside quotes.
  2. Asking to clone the project inside the src folder as the root folder.

How to push to the cloud?

To push on the google cloud project we can use the following command.

clasp -P src/ push

It'll push everything inside src folder to your apps script cloud project.

Prepping To Push To Git Repo

A bonus tip, remember to add the following files inside gitignore, before pushing your project on GitHub.

src/.clasp.json

src/appsscript.json

KCL.png

Conclusion

So, this was a brief blog on settings for apps script on local computer. Now you can edit your Apps Scripts projects in your favorite IDE.

Thanks for reading. I am Nibesh Khadka from Khadka's Coding Lounge. We can write add-ons and custom Apps Script for automation for your projects. Hire Us, Like, Share and Subscribe to the newsletter to get updates on our free content.

kcl_like.png

Did you find this article valuable?

Support Nibesh Khadka by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this