Add GasPackᵐ to an existing project

GasPackᵐ slots into any existing Apps Script project that uses clasp. You don't need to restructure your code — just drop in a manifest and start installing packages.

1

Navigate to your project

Open your terminal and go to your existing Apps Script project:

cd my-gas-project
2

Initialize GasPackᵐ

Run gpm init to set up package management in place:

$ gpm init
Created gpm.json
Project initialized for GasPackᵐ

This creates a gpm.json manifest tracking your dependencies. Your existing Code.js, appsscript.json, and .clasp.json are untouched.

Starting fresh instead? Skip to Start from a Template below.

Start from a template

gpm create project <name> scaffolds a new Apps Script project with GasPackᵐ wired in from the start — manifest, modules folder, build config, and (optionally) a clasp project created for you.

$ gpm create project my-gas-app
Creating project my-gas-app...
Created new Apps Script project my-gas-app
? Create an Apps Script project now (runs clasp create)? Yes

What you get

my-gas-app/
├── src/
│   └── Code.js          # Entry point with a sample main() function
├── modules/             # Your in-project modules go here
├── appsscript.json      # Apps Script manifest (scopes, timezone)
├── gpm.json             # GasPackᵐ manifest (dependencies, build config)
├── gaspack.json.js      # Build config (entry points, module wrapping)
├── package.json         # npm devDependencies for the build toolchain
├── .clasp.json          # clasp configuration (rootDir patched to build/)
├── .gitignore
└── README.md

Built-in template

The default template ships with a minimal Code.js that demonstrates how to read project metadata, list installed packages, and call into a versioned namespace. It's the smallest useful starting point — enough to clasp-push and see your project on Apps Script, nothing more.

Want a more featureful starting point?

For projects that need bundling, environments, unit tests, lint/format hooks, or a structured client/server split for HtmlService, consider Dmitry Kostyuk's apps-script-engine-template — a community-maintained Apps Script project template that includes webpack, multiple environments, custom dependency loading, Jest, ESLint, Prettier, and Husky hooks out-of-the-box. Clone it, then run gpm init at the project root to add the GasPackᵐ manifest alongside.

Install Packages

Search the registry and install packages to add functionality to your project.

Search for packages

Find packages by name or keyword:

$ gpm search "sheets"
Found 3 packages:
@user.gmail.com/sheet-utils v1.2.0
Utility functions for Google Sheets
@company.com/data-sync v2.0.1
Sync data between Sheets and external APIs

View package details

Get more information about a package before installing:

gpm info @user.gmail.com/sheet-utils

Install a package

$ gpm install @user.gmail.com/sheet-utils
📦 Installing @user.gmail.com/sheet-utils...
Installed @user.gmail.com/sheet-utils@1.2.0
Modules: utils, formatters
Location: gpm_modules/@user.gmail.com/sheet-utils/

Install a specific version

gpm install @user.gmail.com/sheet-utils --ver 1.1.0

Lockfile

GasPackᵐ creates a gpm-lock.json file to ensure consistent installs across machines. Commit this file to version control for reproducible builds.

Use Packages in Code

Packages expose their functions via namespaced globals. After building, you can call them directly in your Apps Script code.

Understanding namespaces

Each package module has a unique versioned namespace (like SHEET_UTILS_V1 or LOGGER_V2). The _Vx suffix matches the installed major version, so multiple major versions of a package can coexist in a single project without colliding. Check the package documentation to find its namespace.

Example usage

Assuming you ran gpm install @user.gmail.com/sheet-utils and got sheet-utils@1.2.0, the runtime namespace is SHEET_UTILS_V1:

// Using the SHEET_UTILS_V1 namespace from sheet-utils@1.2.0
function processData() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const data = sheet.getDataRange().getValues();

  // Call package functions via versioned namespace
  const formatted = SHEET_UTILS_V1.formatCurrency(data[0][1]);
  const cleaned = SHEET_UTILS_V1.trimWhitespace(data[0][0]);

  Logger.log(formatted, cleaned);
}

Multiple packages

You can use multiple packages together — each keeps its own versioned namespace:

function runJob() {
  // Using logger@2.x
  LOGGER_V2.info('Starting job...');

  // Using sheet-utils@1.x
  const data = SHEET_UTILS_V1.getSheetData('Sheet1');

  // Using cache-utils@1.x
  CACHE_V1.set('lastRun', new Date().toISOString());

  LOGGER_V2.info('Job complete');
}

Build before testing

Package namespaces are only available after running gpm build. Make sure to build your project before pushing to Apps Script.

Build & Deploy

Bundle your project with all dependencies, then push to Google Apps Script.

Build your project

$ gpm build
Building project with 2 dependencies...
Bundling @user.gmail.com/sheet-utils...
Bundling @user.gmail.com/logger...
Build complete
Output: dist/
Files: 4

Check for updates

See if newer versions are available:

gpm build --check-updates

Push to Apps Script

Use clasp to deploy your built project:

clasp push

Quick iteration

Combine commands for rapid development:

gpm build && clasp push

Build options

FlagDescription
--minifyMinify module code for smaller bundle size
--compactCompact metadata (single-line headers)
--no-headerExclude documentation header from bundle
--check-updatesCheck for available non-breaking updates
--strict-depsTurn dependency warnings into build errors

Manage Dependencies

View, update, and remove packages from your project.

gpm list

View installed packages

# List all packages
gpm list

# Show detailed info
gpm list --verbose

# Show module exports
gpm list --exports

gpm update

Update to latest compatible versions

# Update all packages
gpm update

# Update specific package
gpm update @user.gmail.com/logger

gpm uninstall

Remove a package

gpm uninstall @user.gmail.com/logger

gpm audit

Check for security issues

gpm audit

Shows security grades for all installed packages.

Install all dependencies

When cloning a project or setting up on a new machine, install all dependencies from gpm.json:

$ gpm install
📦 Installing 3 packages...
Installed 3 packages:
• @user.gmail.com/sheet-utils@1.2.0
• @user.gmail.com/logger@2.0.1
• @user.gmail.com/cache-utils@1.0.0
📂 Packages installed in gpm_modules/

Run your project locally Planned

gpm init-local will let you execute your Apps Script project from Node — your own code plus its dependencies — using the gas-fakes emulation layer. No clasp push cycle between every edit; iterate against the same GAS APIs you'd see in production.

What gpm init-local will do

One-time, per project:

  1. Install @mcpher/gas-fakes as a devDependency.
  2. Delegate to npx gas-fakes init for auth (Domain-Wide Delegation for Workspace, Application Default Credentials for consumer Gmail).
  3. Scaffold a tests/local.mjs Node entry that imports gas-fakes and offers a sample call site for the modules in your gpm_modules/.
  4. Add "local": "node tests/local.mjs" to package.json scripts.
  5. Add .env to .gitignore if not already present.

Until it ships, the same flow is doable manually — see Creating Packages → Local execution for the detailed reference and implementation notes.

Why this matters for projects

For consumers (you), local execution closes a real feedback gap. Right now, testing means gpm buildclasp push → run the function from the Apps Script editor → check logs. That's three steps and a network round-trip per change. With gas-fakes plugged in, the same script runs from node in milliseconds — useful for both rapid iteration and CI-friendly automated tests.

External references

  • gas-fakes — Node.js emulation layer for Apps Script (MIT, by Bruce McPherson). Translates GAS service calls into Google Workspace API requests.
  • apps-script-engine-template — a community-maintained project template (webpack, environments, Jest, ESLint) that pairs well with the gas-fakes local-execution pattern.

gas-fakes hits real APIs

It's an emulation layer, not an offline simulator — calls to DriveApp, SpreadsheetApp, etc. hit real Google Workspace APIs against your account. Use test resources you don't mind touching, and gitignore your .env credentials. Final fidelity checks should still happen on the live Apps Script runtime before deploying to production.