Skip to content

Add node engines tag#275

Open
confused-bears wants to merge 1 commit intotree-sitter:masterfrom
confused-bears:add-node-engines-tag
Open

Add node engines tag#275
confused-bears wants to merge 1 commit intotree-sitter:masterfrom
confused-bears:add-node-engines-tag

Conversation

@confused-bears
Copy link

Summary

This PR adds the "engines" field to package.json to explicitly declare which Node.js versions are supported by tree-sitter.

Installation failures can occur if users try to install the package on unsupported Node versions.

  • Users on unsupported Node versions will receive a warning from npm when attempting to install.
  • This does not prevent installation entirely, but improves transparency about required Node versions and reduces failed builds.

Why this change is suggested

During development, I ran into installation issues on Node 24:

image

This happens because:

  • tree-sitter ships prebuilt binaries for specific Node versions (18, 20, 22).
  • Node 24 does not have a matching prebuilt binary.
  • npm falls back to compiling from source, which fails due to ABI and compiler differences.

Adding the "engines" field prevents users from accidentally attempting to install the package on unsupported Node versions and improves the visibility of required Node versions.

Repro Steps

  1. Navigate to master branch of node-tree-sitter
  2. Switch node version to incompatible, clear out node_modules directory and reinstall packages:
nvm use 24
rm -rf node_modules package-lock.json
npm install
  1. Observe build error like below
image

Testing Versions

I manually tested the bounds for node versions by using the command:

nvm use <version>
rm -rf node_modules package-lock.json
npm install

with versions 16 through 24.

New behavior -- show warning on error

npm is now aware of the compatible node versions. Incompatible node versions will still fail to install the package, but the user now has a better understanding of what they can do to resolve the issue.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant