Skip to content

Commit 4687374

Browse files
authored
docs: add pnpm and yarn README guidance
1 parent 8f957d1 commit 4687374

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
1414
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)
1515

16-
The `postinstall` script helper for handling native bindings in legacy `npm` versions, this is a reimplementation of the [`node-install`][node-install] functionality from [`esbuild`][esbuild] for [`napi-rs`][napi-rs] ecosystem packages like [`rollup`][rollup], [`@swc/core`][swc-core] and [`unrs-resolver`][unrs-resolver].
16+
The `postinstall` script helper for handling native bindings in `npm` versions
17+
affected by [npm/cli#4828](https://github.com/npm/cli/issues/4828). This is a
18+
reimplementation of the [`node-install`][node-install] functionality from
19+
[`esbuild`][esbuild] for [`napi-rs`][napi-rs] ecosystem packages like
20+
[`rollup`][rollup], [`@swc/core`][swc-core] and [`unrs-resolver`][unrs-resolver].
1721

1822
For more details, please refer to the following issues:
1923

@@ -24,6 +28,8 @@ For more details, please refer to the following issues:
2428
## TOC <!-- omit in toc -->
2529

2630
- [Usage](#usage)
31+
- [TL;DR for package users](#tldr-for-package-users)
32+
- [Notes for package authors](#notes-for-package-authors)
2733
- [Install](#install)
2834
- [CLI](#cli)
2935
- [API](#api)
@@ -37,6 +43,28 @@ For more details, please refer to the following issues:
3743

3844
## Usage
3945

46+
### TL;DR for package users
47+
48+
- If you only see `napi-postinstall` in a dependency's `postinstall` script,
49+
this script is mainly a workaround for `npm` users affected by
50+
[npm/cli#4828](https://github.com/npm/cli/issues/4828).
51+
- For `pnpm`/`yarn` users, it is usually safe to ignore or disable this script
52+
when install works and your dependency can load its native binary normally.
53+
- If your install fails to resolve the native binding package, re-enable
54+
scripts and run install again.
55+
- For `pnpm`, you can silence the warning by adding the package name to
56+
[`ignoredBuiltDependencies`][ignored-built-dependencies].
57+
58+
### Notes for package authors
59+
60+
You can copy this note into your own README:
61+
62+
> This package uses `napi-postinstall` as a compatibility workaround for older
63+
> `npm` behavior (see [npm/cli#4828](https://github.com/npm/cli/issues/4828)).
64+
> If you are using `pnpm` or `yarn`, install usually works without running this
65+
> script. If your package manager warns about ignored build scripts, you can
66+
> allow this script or ignore it when installation already works.
67+
4068
### Install
4169

4270
```sh
@@ -142,6 +170,7 @@ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.m
142170
[rollup]: https://github.com/rollup/rollup
143171
[swc-core]: https://github.com/swc-project/swc
144172
[unrs-resolver]: https://github.com/unrs/unrs-resolver
173+
[ignored-built-dependencies]: https://pnpm.io/settings#ignoredbuiltdependencies
145174
[1stG.me]: https://www.1stG.me
146175
[JounQin]: https://github.com/JounQin
147176
[MIT]: http://opensource.org/licenses/MIT

0 commit comments

Comments
 (0)