This guide covers routine deployments after your environment is set up.
├─ Never deployed this project before?
│ └─→ Read: setup-cli-based.md
│
├─ Already have a deployment running?
│ └─→ You're in the right place! Continue below.
│
└─ Not sure if you have a deployment?
└─→ Run: npx clasp deployments
├─ See a deployment listed? Continue below.
└─ See "No deployments"? Read: setup-cli-based.md
For complete initial setup (Node.js, nvm, clasp, authentication, triggers), see setup-cli-based.md.
- Open a terminal in the project directory.
- Activate the project Node.js version:
If you see "command not found: npx" or similar errors, see the CLI Setup Guide for troubleshooting.
nvm use
- If dependencies were updated, rerun
npm install.
If this is your first deployment, stop here and follow the complete setup guide:
That guide covers:
- Creating your initial deployment
- Setting up calendar triggers
- Finding calendar IDs
- Initial authorization and testing
Once you've completed the first-time setup, return here for all future deployments.
This command pushes your local files (scripts/SyncCalendarsIntoOne.gs, scripts/BatchRequests.gs, scripts/appsscript.json) to Google Apps Script, updating the "HEAD" (draft) version of your project.
npm run deployNote: The project files are located in the scripts/ directory to avoid scanning node_modules and other unnecessary files.
Create a new, immutable version of your script. This provides a stable snapshot that you can deploy.
- Draft a version description. Keep it short and descriptive (e.g., "Fix sync logic for all-day events").
- Run the versioning command:
This command will output a new version number. Note it for the next step.
npm run clasp:version "<your description>"
Update the production deployment to use the new version you just created.
-
Find your Deployment ID. If you don't have it handy, run:
npx clasp deployments
You will see a list of deployments. The one you want is likely the only one listed.
-
Deploy the new version: Replace
{DEPLOYMENT_ID}and{VERSION_NUMBER}with the values from the previous steps.npx clasp deploy --deploymentId {DEPLOYMENT_ID} --versionNumber {VERSION_NUMBER}
Your new code is now live and stable. Your triggers will run against this newly deployed version.
See what the script is doing and any errors:
npm run clasp:logsOr in the Apps Script UI: View → Logs or Execution log.
Issue: "Push failed" or npm run deploy hangs
- Solution 1: Check you're logged in:
npx clasp login. - Solution 2: Verify
scripts/.clasp.jsonhas the correctscriptIdand"rootDir": ".". - Solution 3: Ensure you have write access to the Apps Script project.
- Solution 4: Check your network connection and try again. Sometimes Google's API can be slow or timeout.
Issue: Changes Not Appearing After Deployment
- Solution: Make sure you completed all three steps:
push,version, anddeploy. Simply pushing the code does not make it live in a versioned deployment.
- Quick access:
npm run clasp:open - Find your Script ID in
scripts/.clasp.json.
| Command | Description |
|---|---|
npm run deploy |
Push local code to update the HEAD deployment on Apps Script. |
npm run clasp:create |
Create a new Apps Script project (first-time only). |
npm run clasp:open |
Open the project in the browser. |
npm run clasp:logs |
View recent execution logs. |
npm run clasp:pull |
Pull changes from Apps Script to your local files. |
npm run clasp:version |
Create a new numbered version of the script. |
npm run clasp:deploy |
Deploy a specific version to a deployment ID. |