mapbox / mapbox/node-pre-gyp

node v4 error when using napi_versions/napi_build_versions

Open
#396 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.2k
Forks
271
Avg merge
23h 40m
Merged PRs (30d)
2

Description

I found that if you add:

```
"package_name": "{module_name}-v{version}-{platform}-{arch}-napi-v{napi_build_version}.tar.gz",
"napi_versions": [
1,
2
]
```

To the `package.json` `binary` property of a node-pre-gyp enabled module it will lead to this error with node v4:

```
./node_modules/.bin/node-pre-gyp rebuild --loglevel=error
/Users/danespringmeyer/projects/node-sqlite3/node_modules/node-pre-gyp/lib/util/napi.js:105
if (!napi_build_versions.includes(napi_version)) napi_build_versions.push(napi_version);
^

TypeError: napi_build_versions.includes is not a function
```

This looks to be because `Array.includes` is not supported with node v4, so we'll either need to use a polyfill or use `Array.indexOf` instead.

@jschlight two questions for you:

- Should we try to support node v4 at all? If not, should this just throw with an easier to understand error?
- If we should support node v4, do you have bandwidth to provide a PR to fix this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/util/napi.js around line 105 and reproduce the package.json binary configuration using the node-pre-gyp rebuild command shown. Determine the project’s Node v4 support policy, then verify that this configuration no longer produces the reported TypeError or gives a clear unsupported-version error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.