Skip to content
Latchkey

pre-commit language: node Environments

language: node makes pre-commit build a Node environment for the hook, installing the package and any dependencies.

Node hooks like prettier and eslint run in their own pre-commit-managed Node environment, isolated from your project node_modules.

What it does

For a language: node hook, pre-commit provisions a Node environment (downloading the requested Node version if it is not present), installs the hook package and additional_dependencies, and runs entry. The environment is cached like every other hook env.

Common usage

.pre-commit-config.yaml
- repo: https://github.com/pre-commit/mirrors-prettier
  rev: v3.1.0
  hooks:
    - id: prettier
      additional_dependencies:
        - prettier@3.3.0
        - prettier-plugin-svelte@3.2.0

Keys

KeyWhat it does
language: nodeBuild a Node environment for the hook
language_versionNode version, e.g. 20.11.1
additional_dependenciesExtra npm packages (pin with name@version)
entryCommand run in the Node env
defaultUse the system Node instead of downloading one

In CI

If language_version names a Node version, pre-commit downloads it via its node provisioner, which needs network access; behind a proxy or on an offline runner this fails. Setting language_version: default uses the runner Node from setup-node instead. Cache ~/.cache/pre-commit so the Node env and node_modules are reused.

Common errors in CI

A hang or failure on "[INFO] Installing environment for ... node" often means the Node download is blocked; use language_version: default with a pre-installed Node. "npm ERR! ... ETIMEDOUT" during env build is the npm install failing on a restricted network. A mismatched plugin version in additional_dependencies surfaces as a prettier or eslint plugin-not-found error.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →