# require-from-drive

> Load JSON from Google Drive. This is a way to make sure configuration or secrets are always the same from person to person and server to server.

Latest version **4.0.4** (published 2026-09-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install require-from-drive
pnpm add require-from-drive
yarn add require-from-drive
bun add require-from-drive
```

Provides the command `generate-secret`.

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.0.4 |
| Published | 2026-09-09 |
| First published | 2016-10-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=24.0.0 |
| Dependencies | 0 |
| Unpacked size | 297.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Tyler Murphy |
| Maintainers | tyler-murphy |
| Keywords | require, google, drive |

## Links

- npm: https://www.npmjs.com/package/require-from-drive
- Repository: https://github.com/Tyler-Murphy/require-from-drive
- Homepage: https://github.com/Tyler-Murphy/require-from-drive#readme
- Issues: https://github.com/Tyler-Murphy/require-from-drive/issues
- npm.io page: https://npm.io/package/require-from-drive

## Recent versions

- 4.0.4 (latest) — 2026-09-09
- 4.0.3 — 2025-08-04
- 4.0.2 — 2025-08-04
- 3.0.0 — 2023-10-27
- 2.1.5 — 2022-01-22
- 2.1.4 — 2021-05-24
- 2.1.3 — 2020-09-15
- 2.1.2 — 2019-11-04
- 2.1.1 — 2019-11-04
- 2.1.0 — 2019-10-21
- 2.0.0 — 2019-10-19
- 1.1.0 — 2019-08-14
- 1.0.4 — 2019-02-15
- 1.0.3 — 2019-02-15
- 1.0.2 — 2017-03-10
- … 2 more at https://npm.io/package/require-from-drive/versions

## README

This library lets you load JSON-containing Google Docs. Loading is fingerprint-protected on macOS laptops or can be token-protected for servers and other computers.

There are two parts:
  - an Apps Script you'll put in Google Drive
  - A node module to load things from Google drive

### Install

**As of v4, node >= 24.0.0 is required and macOS with a fingerprint reader is recommended**

```
npm install --save require-from-drive
```

### Use

**IMPORTANT: Each time the apps script is changed, you'll need to deploy a new version as a web app. Otherwise, your changes won't end up in the live version.**

First, follow these steps to set up Google Drive:

1. Create a folder on Google Drive. Name it something like "app secrets"
2. Create an apps script in the folder, and paste the contents of `packages/appsScript/server.js` in it.
3. Get the folder ID and put it in the Apps Script's `thisFolderId` variable
4. Create a blank, single-column spreadsheet in the folder, and paste its entire URL in the Apps Script's `spreadsheetLoggingUrl` variable. Logs about requests will be stored in this spreadsheet.
5. Deploy as a web app, and copy the url.
6. Set the local `REQUIRE_FROM_DRIVE_SERVER_ADDRESS` environment variable to the web app url
7. Run `npx require-from-drive generate-secret` and follow the prompts to generate a secret. Repeat as necessary to generate separate tokens for each app or server that will request files.
8. Add sub-directories and Google Docs containing JSON. Paths to Docs are relative to the folder containing the apps script

Then do this!

```js
import { requireFromDrive } from 'require-from-drive'

const config = await requireFromDrive({ path: 'path/to/project/config.json' })
```

A memory cache and a file cache are enabled by default. The file cache uses file names prefixed with `.require-from-drive`.

The memory cache can be disabled by setting the `cache` option to `false`. The file cache can be disabled by setting the `cacheInFile` option to `false`.

**IMPORTANT: Because there's a file cache, you should add `.require-from-drive*` to your `.gitignore`**

### Test

To run the Apps Script tests, use the Apps Script IDE to select "test" from the "Run" menu. An error will be thrown and a message will pop up if any test fails.

To run the local tests, run `npm test`. If you're running them for the first time, many will fail. Follow the instructions printed after you run the test command to get set up for testing.

---
_Source: https://npm.io/package/require-from-drive · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
