Skip to content

npm RFC #868 will block this package's install script by default #213

Closed

Description

@JamieMagee

Hi there,

I'm reaching out because unrs-resolver is one of the most depended-on npm packages that runs an install script, and an accepted npm RFC is going to change how those scripts behave.

The RFC blocks dependency install scripts by default during npm install. That's the same thing pnpm, Yarn Berry, Bun, and Deno already do. Users opt back in per package through a new allowScripts field in package.json (or the npm approve-scripts command). The motivation is the run of supply-chain attacks over the last couple of years that used postinstall hooks to run code the moment a package landed in the tree.

For unrs-resolver, the script that's affected is:

"postinstall": "node postinstall.js"

That script downloads or builds something unrs-resolver needs to work, so under the new default it won't run unless the user adds unrs-resolver to their allowScripts. Installs that skip it will likely fail at runtime with a missing-binary error, which is a confusing failure mode for your users. The most robust fix is to move that work to first use, the first time the package is actually run, so it keeps working with no allowlist entry. If it has to stay at install time, please document the allowScripts line prominently in your README.

I wanted to flag this early so you've got time to plan rather than find out when the install warnings start showing up. The full RFC is here: npm/rfcs#868. Happy to answer any questions.

Activity

  1. JounQin commented on Jun 2, 2026

    @JounQin
    Member

    Thanks, that's fine for this package.

  2. kstrasters-pj commented on Jun 3, 2026

    @kstrasters-pj

    @JounQin
    This is impacting me as the post install is now not running by default. We have omit=optional and since this script is no longer running as of 1.12.2 we are forced to look for options to force this to work?

  3. JounQin commented on Jun 3, 2026

    @JounQin
    Member

    @kstrasters-pj Why you prefer postinstall over optionalDependencies by the way.

    For yarn, there is enableScripts: true.

    For the new npm, there will be npm approve-scripts.

    For pnpm, there is pnpm approve-builds unrs-resolver.

  4. kstrasters-pj commented on Jun 3, 2026

    @kstrasters-pj

    @JounQin

    This is a setting i inherited, ther eis discussion around if it should stay so i can't answer your question.

    Should unrs-resolver be impacted by this already? As of 1.12.2 it seems like the postinstall isn't running. is that intended? It looks like the RFC isn't merged, so is that a bug or did something change?

  5. JounQin commented on Jun 3, 2026

    @JounQin
    Member

    That's unexpected, could you prepare a reproduction?

  6. kstrasters-pj commented on Jun 3, 2026

    @kstrasters-pj

    That's unexpected, could you prepare a reproduction?

    MacBook Pro
    Apple M2 -> Tahoe 26.5

    just updated from 1.11.1 -> 1.12.2

    on node 22.13.0 with omit=optional.
    (oddly it does appear that node 24 works, but i haven't nailed down exactly when this fixes, so don't hold me to this yet)

    When i npm i/npm ci on my branch with this version of unrs-resolver i receive

    
    Error: ● Validation Error:
    
      Preset jest-preset-angular not found relative to rootDir
    

    from jest

    we tracked this down to the requisite @uns resolver missing, we are able to fix this by manually running the postinstall in our postinstall, but that's obviously a hack, unideal.

    This does seem to be working on our Linux box just fine?

    will update if anything we find changes findings

    EDIT
    if i update to Node 24.16.0, clear my node_modules and npm i everything seems happy. i don't really know what this means at the moment

  7. JounQin commented on Jun 3, 2026

    @JounQin
    Member

    It seems a npm bug but hard to be reproduced, I don't think it can be fixed on our side without a GitHub repo reproduction.

  8. kstrasters-pj commented on Jun 3, 2026

    @kstrasters-pj

    It seems a npm bug but hard to be reproduced, I don't think it can be fixed on our side without a GitHub repo reproduction.

    85217e3#diff-fff9f6b30324b6ed7184ec2ac9e0d1eb007dc997e9465a9cb1105b7f478c305aR542

    We were looking at some commits and found that 1.12.2 doesn't have the (same) fallback env trigger? Is it possible that could be contributing?

  9. kstrasters-pj commented on Jun 4, 2026

    @kstrasters-pj

    @JounQin
    Alright, i guess the primary concern is that we didn't change our node version, all we did was change our unrs-resolver version and things changed/regressed. I feel like something had to have changed on your end to have caused that?

    22.13.0 was working fine on 1.11.1

  10. JounQin commented on Jun 4, 2026

    @JounQin
    Member

    @kstrasters-pj Again, a reproduction is required if you think it's a regression on our side, otherwise I can't do anything. We set the postinstall script correctly as you can see, you can manually run it successfully, so I don't think that's controlled by us.

  11. kstrasters-pj commented on Jun 4, 2026

    @kstrasters-pj

    @JounQin I don't know if this will work, i'm not familiar with this app at all really, but i was able to reproduce it here
    https://replit.com/join/gmwlskaitz-kstrasters

    inside the Shell area, navigating to workspace/sandbox and running nvm use 22 or nvm use 24 depending on which thing you want to rest, then closing the terminal with the "X" to get a new terminal on the node version.

    remove the node_modules, npm i omit=optional and see that you don't get anything inside the @unrs directory on 22, but do on 24

  12. Standard8 commented on Jun 27, 2026

    @Standard8

    Thanks, that's fine for this package.

    I'm slightly confused as to the exact meaning of this. I'm assuming you don't think any changes are necessary.

    The suggestion from the reporter was:

    The most robust fix is to move that work to first use, the first time the package is actually run, so it keeps working with no allowlist entry. If it has to stay at install time, please document the allowScripts line prominently in your README.

    Please could one of these actions be undertaken to either avoid the errors, or document why it isn't being changed, and the consequences of not allowing it?

  13. aaltat commented on Jul 13, 2026

    @aaltat

    Because npm 12 is out and post install scripts are blocked by default, fixing the install script would be nice, there is documentation how the migration can be done in https://installsafe.dev/. If fixing is not possible, for any reason, it would be good to document why it is not and what it affects.

  14. ehoogeveen-medweb commented on Jul 13, 2026

    @ehoogeveen-medweb

    IIUC the point of the install script is to work around bugs like npm/cli#4828 that were (hopefully completely) resolved in later releases of npm v11. If so, it's fine for npm v12 to ignore it.

    In particular, the script ensures that the matching platform-specific optional dependency (native binding) is properly linked/activated.

  15. mysticflute commented on Sep 16, 2026

    @mysticflute

    Thanks, that's fine for this package.

    resolved in later releases of npm v11. If so, it's fine for npm v12 to ignore it.

    So in seems in this case a note could be added to the README, indicating how people can know if they need to do npm deny-scripts or nom approve-scripts based on the criteria?

  16. JounQin commented on Sep 16, 2026

    @JounQin
    Member

    @mysticflute Indeed, would you like to raise a PR for it?

  17. mysticflute commented on Sep 16, 2026

    @mysticflute

    @JounQin I would be happy to, though I need more context about when the script is needed to run or can be skipped.

    I found a few examples of how other packages are documenting it:

    I can submit a PR following a similar format, but I need a bit more explanation about 1) how can the user determine if they need the script, and 2) what is the alternative option if a user wants to run it manually, instead of allowscript.

  18. JounQin commented on Sep 17, 2026

    @JounQin
    Member
    1. only npm v11- users may meet issues without postinstall
    2. they can always remove node_modules and fresh install, or install with the wasm package @unrs/resolver-binding-wasm32-wasi instead
  19. JounQin commented on Oct 20, 2026

    @JounQin
    Member

    After investigation, I decide to move postinstall script to runtime fallback check instead, the fallback logic is actually already there: napi-postinstall/fallback for WASI (WebContainer), see also un-ts/napi-postinstall#75, it'll be adopted into unrs-resolver soon later.

  20. added a commit that references this issue on Oct 31, 2026
    babb1cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions