npm install scripts: which scraping packages still run code

npm 12 blocks dependency install scripts by default. A dated check of 30 npm and PyPI scraping packages, plus tested ways to see and control install code.

Rack with rows of locks being checked one by one, scraping packages and their install scripts
Quick summary · TL;DR
  1. If npm 12 just warned you about blocked install scripts, nothing has run and nothing is broken yet. npm 12.0.0 (8 July 2026) runs a dependency's preinstall, install and postinstall hooks only when allowScripts in your package.json lists it. The ones it skipped are printed at the end.
  2. Only 4 of 16 common npm scraping packages still ship an install script. They were puppeteer, canvas, esbuild and @sentry/cli on 5 Nov 2026. An npm 12.2.2 dry run of all 16 at those versions, 426 packages in total, blocked those four and nothing else.
  3. Run npm install --dry-run on npm 12 before you approve anything. It resolves the tree and runs none of it. Each blocked package is printed with its exact script text, for example esbuild@0.28.2 (postinstall: node install.js).
  4. On PyPI the question is whether a wheel exists, and for these 14 it does. On Python 3.13 and 3.15, for macOS arm64 and Linux x86_64, every package and every dependency resolved to wheels. pip install --only-binary :all: costs nothing on those targets.

If you just upgraded to npm 12 and your install ended with npm warn install-scripts 1 package had install scripts blocked, nothing is broken yet. npm install scripts are the preinstall, install and postinstall hooks a package can run on your machine during npm install. Since npm 12.0.0 on 8 July 2026, dependencies don’t get to run them unless your project’s allowScripts says so.

To find which scraping packages still ship install code, this Lab read the public registry data for 16 npm and 14 PyPI packages that scraping stacks use on 5 November 2026 (UTC). None of their code was run. Four npm packages declare an install script, and none of the other 422 packages in their combined dependency tree do. On PyPI, every package checked has a wheel for Python 3.13 and 3.15 on macOS arm64 and Linux x86_64, so pip has no reason to run a build script for them there.

The two scripts that produced the data are printed near the end, so you can rerun them against your own lockfile.

What npm install scripts are

npm runs three lifecycle hooks of a dependency during install, in this order: preinstall, install, postinstall. Two quieter cases also run code at install time:

  • Implicit node-gyp. A package with a binding.gyp file in its root and no install or preinstall script of its own gets treated as node-gyp rebuild and compiled, per npm’s scripts docs (npm 12.2.2, checked 5 Nov 2026). It can opt out with "gypfile": false, per the package.json docs.
  • prepare. For git dependencies, and local folders installed as links, prepare also runs at install time.

Install time is the part attackers care about, because the code runs there before your tests or scanners do. Microsoft’s ChainDrop write-up (4 Aug 2026) describes a worm across more than 400 npm packages. It typically ran from a preinstall hook and spread by republishing packages with stolen npm publish tokens.

What npm 12 changed

The npm 12.0.0 release notes (8 Jul 2026) are blunt about it: dependency lifecycle scripts are now blocked by default unless the root package’s allowScripts policy allows them. The same release set allow-git and allow-remote to none, so git and tarball-URL dependencies no longer install unless you opt in. The latest npm on 5 November 2026 was 12.2.2.

Your own project’s scripts still run. The block covers dependencies.

Here’s how the three tools behaved on the same harmless test package, whose postinstall only prints hello-postinstall: postinstall ran:

npm 11.11.0 ran the script during a plain npm install, but npm hides script output by default, so the line only showed up with --foreground-scripts. npm 12.2.2 installed the package, skipped the script and said so.

Later npm 11 releases sit in between. The approve command first ships with npm 11.16.0 (27 May 2026), and on npm 11.21.2 the test script still ran but the install warned that it was not yet covered by allowScripts. ls, approve and --strict-allow-scripts worked there too, so you can build the allow-list before upgrading. The pnpm column comes from pnpm’s docs only, see the pnpm section below.

Which scraping packages run install scripts

The packages cover each layer of a typical web scraping architecture: browsers, HTTP clients, parsers, proxy agents and native helpers. The npm side, latest versions on 5 November 2026 between 23:29 and 23:31 UTC. “Install script” is the exact text from the registry manifest. “Tree” is the full dependency tree npm resolved for that one package, with every platform’s optional packages included.

PackageVersionInstall scriptProvenanceTreeOthers in tree with scripts
playwright1.65.0noneyes20
puppeteer25.16.0postinstall: node install.mjsyes270
puppeteer-core25.16.0noneyes250
crawlee3.18.2noneyes2930
cheerio1.2.0noneno230
jsdom31.0.0noneyes280
got-scraping4.2.2noneyes490
axios1.21.0noneyes270
undici8.12.4noneyes10
https-proxy-agent9.1.0noneyes50
socks-proxy-agent10.1.0noneyes70
sharp0.35.5noneyes320
better-sqlite313.0.3none (gypfile: false)yes20
canvas3.2.3install: prebuild-install -r napi || node-gyp rebuildno370
esbuild0.28.2postinstall: node install.jsyes270
@sentry/cli3.8.2postinstall: node ./scripts/install.jsno140

“Provenance” means the registry lists a SLSA provenance attestation for that version (dist.attestations). Crawlee’s tree is the big one at 293 packages, and not one of them has an install script.

Some hooks are recent history. The registry’s version list shows when each package last shipped one:

  • sharp had install: node install/check.js || npm run build up to 0.34.5. 0.35.0, published 10 June 2026, has none and pulls its binary from 25 optional platform packages.
  • better-sqlite3 had install: node-gyp rebuild up to 13.0.1. 13.0.2 (29 July 2026) ships prebuilt .node files for each platform inside the tarball and sets "gypfile": false, so npm doesn’t build it, even though binding.gyp is still in the package.
  • playwright dropped install: node install.js in 1.38.0 (13 September 2023). Browsers come from a separate npx playwright install you run yourself.
  • puppeteer-core has had no install hook since 2.1.1 in February 2020.

What each install script does

Reading the script text is the whole point, so here’s what each of the four does, from its own source in the published tarball:

  • puppeteer install.mjs calls downloadBrowsers(), which downloads Chrome for Testing and chrome-headless-shell into Puppeteer’s cache. It respects PUPPETEER_SKIP_DOWNLOAD. If the script was blocked, Puppeteer’s install guide (checked 5 Nov 2026) gives npx puppeteer browsers install to fetch the browser yourself. puppeteer-core never runs this step.
  • esbuild install.js checks that the platform binary from its optional packages (26 of them) is in place and runs it to validate the version. If that package is missing, it tries a separate npm install of it, then a direct download from registry.npmjs.org.
  • @sentry/cli scripts/install.js exits straight away if its platform package from optionalDependencies resolved. Otherwise it downloads the CLI binary from Sentry’s CDN and checks a checksum. SENTRYCLI_SKIP_DOWNLOAD=1 skips it.
  • canvas tries prebuild-install for a prebuilt binary and falls back to node-gyp rebuild, a full native compile. It’s the only one of the four that can end in a compiler run on your machine.

Three of the four are fetch-or-verify steps for a binary that, in the normal case, already arrived as an optional package. If puppeteer is the one blocked, approve it or install the browser yourself. The Puppeteer proxy guide and the Playwright proxy guide cover the next step, pointing that browser at a proxy.

The proxy layer itself carries no install code. https-proxy-agent, socks-proxy-agent, undici and got-scraping, the packages most Node scrapers use to send traffic through rotating residential proxies or any other proxy, declared no install scripts and pulled none in.

See npm install scripts first

On npm 12, a dry run is a free audit. It resolves the tree, prints what it would block, and runs nothing:

npm install esbuild@0.28.2 --dry-run
add @esbuild/darwin-arm64 0.28.2
add esbuild 0.28.2

added 2 packages in 296ms
npm warn install-scripts 1 package had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts   esbuild@0.28.2 (postinstall: node install.js)

For a single package, npm view reads the manifest. On npm 12, --json always returns an array:

npm view esbuild@0.28.2 scripts.postinstall dist.attestations.provenance --json
[
  {
    "scripts.postinstall": "node install.js",
    "dist.attestations.provenance": {
      "predicateType": "https://slsa.dev/provenance/v1"
    }
  }
]

And for a project you already have, npm install --package-lock-only --ignore-scripts writes a lockfile without installing anything. Every package with a script gets "hasInstallScript": true in package-lock.json, so a quick grep shows them.

Approve or block npm install scripts

After an install, npm 12 lists anything it skipped. These are the commands from npm’s install-scripts docs (checked 5 Nov 2026), and this is what they printed on the test package:

npm install-scripts ls          # read-only list of unreviewed scripts
npm install-scripts approve hello-postinstall
npm rebuild --foreground-scripts
1 package has install scripts blocked because they are not covered by allowScripts:
  hello-postinstall@1.0.0 (postinstall: node -e "console.log('hello-postinstall: postinstall ran')")
...
npm notice run hello-postinstall@1.0.0 postinstall
hello-postinstall: postinstall ran
rebuilt dependencies successfully

approve writes the entry into allowScripts in package.json. For registry packages it pins the version by default ("esbuild@0.28.2": true in a test project), so an upgrade needs a fresh review. That’s the behaviour you want. --no-allow-scripts-pin writes a name-only "esbuild": true instead. Don’t hand-write a range: npm 12.2.2 ignored an "esbuild@^0.28.0": true entry with a warning that semver ranges aren’t allowed, and esbuild 0.28.2 stayed blocked. npm install-scripts prune drops entries for removed packages. A local tarball gets keyed by its file path instead. npm install-scripts deny <pkg> writes a false entry that survives a later approve --all.

Approval only matches packages already in node_modules. In an empty project, npm install-scripts approve canvas stopped with npm error code ENOMATCH, so the order is install (scripts stay blocked), approve, then rebuild. Early coverage of npm 12 calls the command npm approve-scripts, and on 12.2.2 that name still works as an alias for npm install-scripts approve.

In CI, --strict-allow-scripts (or strict-allow-scripts=true in .npmrc) turns the warning into a failed install. On the test package it stopped with npm error code ESTRICTALLOWSCRIPTS.

ignore-scripts is the older, blunter switch. With ignore-scripts=true in .npmrc, npm 11.11.0 installed the test package and printed nothing from it, even with --foreground-scripts. It also skips pre and post hooks of your own npm run scripts, which catches people out. For one-off npx and global installs, where there’s no project package.json, npm’s config docs say to pass --allow-scripts=canvas,esbuild on the command line instead. This Lab didn’t test that path. Inside a project the flag is refused: npm install --allow-scripts=esbuild stopped with npm error code EALLOWSCRIPTS.

pnpm allowBuilds

pnpm got here first. pnpm 10.0.0 (7 Jan 2025) stopped running dependency lifecycle scripts by default and used onlyBuiltDependencies as the allow-list. According to pnpm’s build settings docs (checked 5 Nov 2026), pnpm 11 removed onlyBuiltDependencies, neverBuiltDependencies and ignoredBuiltDependencies and replaced them with one map in pnpm-workspace.yaml. pnpm 12 kept it, and 12.16.1 was the latest pnpm on 5 November 2026:

allowBuilds:
  esbuild: true
  canvas: false

strictDepBuilds defaults to true, so an unreviewed build fails the install with ERR_PNPM_IGNORED_BUILDS. pnpm approve-builds writes the entries for you. Plenty of older guides still tell you to add onlyBuiltDependencies to package.json, and that setting is gone from pnpm 11 on. pnpm wasn’t run in this Lab.

Python packages: wheels and sdists

pip has no install hooks. Its version of install-time code is the build step: when pip can’t find a wheel that fits your Python and platform, it downloads the sdist and runs the package’s build backend, which for a setuptools project means its setup.py. On a harmless local sdist, pip install -v (pip 26.3) printed pm-hello-build-demo: setup.py ran during install three times in one install, once each for metadata, build requirements and the wheel. Without -v, pip showed none of it. With --only-binary :all: it refused:

pip install --only-binary :all: --find-links dist pm-hello-build-demo
ERROR: Could not find a version that satisfies the requirement pm-hello-build-demo (from versions: none)
ERROR: No matching distribution found for pm-hello-build-demo

So the PyPI question is whether a wheel exists. Latest versions on 5 November 2026, read from PyPI’s JSON and Simple APIs, with each full dependency tree resolved wheels-only for CPython 3.13 and 3.15 (released 9 October 2026, per python.org) on macOS arm64 and Linux x86_64 with glibc 2.39:

PackageVersionReleasedWheelsHas sdistWheel-only tree on all 4 targetsPEP 740 provenance
requests2.34.22026-05-141yesyesall files
httpx0.28.12024-12-061yesyesnone
aiohttp3.14.52026-10-11160yesyesall files
scrapy2.19.02026-09-101yesyes (45 packages on 3.13, 44 on 3.15)all files
playwright1.64.12026-10-228noyesall files
selenium4.52.02026-10-291yesyesall files
lxml6.1.32026-09-02175yesyesnone
curl_cffi0.17.02026-10-2630yesyesall files
beautifulsoup44.15.02026-06-071yesyesnone
PySocks1.7.12019-09-202yesyesnone
cryptography50.0.22026-09-3058yesyesall files
brotli1.2.12026-10-22142yesyesnone
parsel1.12.12026-09-281yesyesall files
greenlet3.5.62026-09-1478yesyesnone

All 56 resolutions (14 packages, 2 Pythons, 2 platforms) found a wheel for every package in the tree, 64 distinct packages in all, and each one resolved to its latest release except pyee, which playwright caps below 15, so it resolved to 14.0.0. That means pip install --only-binary :all: costs these stacks nothing on those four targets, while a plain pip install would also have picked wheels. Outside those targets the picture can change. 13 of the 14 still publish an sdist, and pip falls back to it on a platform without a wheel, Alpine’s musl among them, which this Lab didn’t check.

You can make it the default for a project with PIP_ONLY_BINARY=:all: in CI, or only-binary = :all: under [install] in pip.conf. When a single package genuinely needs a build, --only-binary :all: --no-binary that-package lets that one through after you’ve read its build files. With PIP_ONLY_BINARY=:all: set, pip 26.3 refused the test sdist with the same No matching distribution found error.

What provenance proves

Eight of the 14 PyPI packages have a PEP 740 attestation on every file, and 13 of 16 npm packages carry SLSA provenance. That tells you which CI workflow built the file and from which repository commit. It doesn’t tell you the code is safe. Microsoft’s ChainDrop analysis notes that the worm had a publishing path for GitHub Actions workflows set up as npm trusted publishers, and that packages published that way can carry valid provenance.

A missing attestation is a fact to note in your review, and the upload date gives it context. httpx 0.28.1 was uploaded on 6 December 2024 and PySocks 1.7.1 on 20 September 2019.

The script behind the table

The npm half reads one manifest per package from the registry and never downloads a tarball:

// check-npm.mjs - read-only: which npm packages declare install-time scripts?
// Usage: node check-npm.mjs pkg1 pkg2 ... > npm.json
const HOOKS = ['preinstall', 'install', 'postinstall'];
const out = [];
for (const name of process.argv.slice(2)) {
  const url = `https://registry.npmjs.org/${name.replace('/', '%2F')}/latest`;
  const m = await (await fetch(url)).json();
  const scripts = Object.fromEntries(
    HOOKS.filter((h) => m.scripts?.[h]).map((h) => [h, m.scripts[h]]));
  const att = m.dist?.attestations;
  out.push({
    name,
    version: m.version,
    installScripts: scripts,            // the exact text npm would run
    gypfile: m.gypfile ?? null,         // false = opted out of the implicit node-gyp build
    provenance: att?.provenance?.predicateType ?? null,
    optionalDependencies: Object.keys(m.optionalDependencies ?? {}).length,
  });
}
console.log(JSON.stringify({ checked: new Date().toISOString(), packages: out }, null, 2));

The tree column came from npm install --package-lock-only --ignore-scripts (npm 11.11.0) in an empty project per package, counting hasInstallScript in the lockfile, and the npm 12.2.2 dry run above confirmed it. npm 12.2.2 ran on Node 24.14.1 and printed an engine warning, since it asks for 24.15 or later. On that Node a bare jsdom resolved to 29.1.1, since 31.0.0 asks for the same engines, and the dry run grew to 436 packages with the same four blocked. Pin versions when you rerun it.

The PyPI half, wheel matching only, with pip’s own tag logic:

# check-pypi.py - would pip get a wheel, or build an sdist, for the latest version?
# Usage: python3 -I check-pypi.py requests httpx ... > pypi.json
import json, sys, urllib.request
from pip._vendor.packaging import tags
from pip._vendor.packaging.utils import parse_wheel_filename

def get(url, accept="application/json"):
    req = urllib.request.Request(url, headers={"Accept": accept})
    with urllib.request.urlopen(req) as r:
        return json.load(r)

def supported(py, plats):
    return set(tags.cpython_tags(python_version=py, platforms=plats)) | \
           set(tags.compatible_tags(python_version=py, platforms=plats))

MAC = list(tags.mac_platforms((14, 0), "arm64"))
LINUX = [f"manylinux_2_{m}_x86_64" for m in range(39, 4, -1)] + \
        ["manylinux2014_x86_64", "manylinux2010_x86_64", "manylinux1_x86_64"]  # glibc 2.39
TARGETS = {f"cp3{m}-{os}": supported((3, m), p)
           for m in (13, 15) for os, p in (("macos-arm64", MAC), ("linux-x86_64", LINUX))}

for name in sys.argv[1:]:
    info = get(f"https://pypi.org/pypi/{name}/json")
    files = [f for f in info["urls"] if not f["yanked"]]
    simple = get(f"https://pypi.org/simple/{name}/", "application/vnd.pypi.simple.v1+json")
    prov = {f["filename"]: f.get("provenance") for f in simple["files"]}
    wheels = [f["filename"] for f in files if f["packagetype"] == "bdist_wheel"]
    has_sdist = any(f["packagetype"] == "sdist" for f in files)
    gets = {t: "wheel" if any(set(parse_wheel_filename(w)[3]) & s for w in wheels)
               else ("sdist build" if has_sdist else "no file") for t, s in TARGETS.items()}
    print(json.dumps({"name": name, "version": info["info"]["version"], "pip_gets": gets,
                      "pep740": sum(1 for f in files if prov.get(f["filename"])),
                      "files": len(files)}))

The dependency trees came from uv pip compile --no-build --python-version 3.15 --python-platform x86_64-manylinux_2_39 (uv 0.12.0) per package and target. --no-build means uv never runs a build, and unlike pip --python-version, uv evaluates environment markers for the target Python. That difference matters: an earlier pass with pip read scrapy’s python_version < "3.14" dependency against the host’s Python 3.12 and gave a wrong answer for 3.15.

Not tested: Windows, Alpine, Yarn, Bun and pnpm itself; whether each blocked package still works at runtime without its script; and real installs on Linux, where only resolution was checked.

npm install scripts on your stack

If you’re on npm 12, run npm install --dry-run on your project once and read the list of npm install scripts it would block. For most scraping stacks it’s short: puppeteer, esbuild, canvas or @sentry/cli if you use them, and possibly nothing else. Approve the ones you’ve read, pin them, and add --strict-allow-scripts to CI so a new script shows up as a failed build, not a warning nobody reads.

Before npm 11.16.0 the only switch is ignore-scripts=true, all or nothing. A current npm 11 already reads allowScripts, so start the list there.

On pnpm 11 or 12, check that your config says allowBuilds. If it still says onlyBuiltDependencies, that line does nothing now.

For Python, pip install --only-binary :all: is free for every package in this table on the four targets checked, so it’s a sensible CI default. When it fails, it’s telling you which package would have run build code, and that’s the one to read before you let it through.

Frequently asked questions

They are the preinstall, install and postinstall lifecycle hooks a package can declare, and npm runs them on your machine during npm install. Two quieter cases run code too. A package with a binding.gyp file and no install script of its own gets an implicit node-gyp rebuild, and prepare runs at install time for git dependencies and local folders installed as links.

Not for dependencies, unless your project allows them. Your own project's scripts still run. For dependencies, npm 12.0.0 (released 8 July 2026) blocks lifecycle scripts by default and lists the skipped ones at the end of the install.

Run npm install-scripts approve with the package name, then npm rebuild to execute the newly approved script. The approve step writes a pinned entry such as esbuild@0.28.2 into allowScripts in package.json. npx and global installs have no project package.json, so npm's docs say to pass --allow-scripts with a comma-separated list there instead. That path wasn't tested here.

ignore-scripts is an all-or-nothing switch that stops every lifecycle script, including pre and post hooks of your own npm run scripts. allowScripts is a per-package allow-list in package.json that npm 12 checks for dependencies. Set both and ignore-scripts wins, so approved packages will not run either.

Only when it builds from an sdist. That happens when no wheel matches your Python and platform, and the build backend it runs is setup.py for a setuptools package. In a local test, pip 26.3 ran a demo setup.py three times in one install, and only pip install -v showed it. pip install --only-binary :all: refuses sdists, so nothing builds.

Not for dependencies by default since pnpm 10.0.0 in January 2025. In pnpm 11 and 12 you allow them per package with allowBuilds in pnpm-workspace.yaml, and strictDepBuilds, on by default, fails the install when a build has not been reviewed. pnpm approve-builds writes the entries for you.

No. A SLSA provenance attestation shows which CI workflow and repository commit produced the file. Microsoft's ChainDrop analysis from August 2026 notes that packages the worm published through GitHub Actions OIDC trusted publishing can carry valid provenance. Treat provenance as one fact in a review, next to the script text and the version history.

Researched and drafted with AI tools, then checked against our publishing rules before it went live: 10 outside links, 4 links to other proxymint pages, no prices and a fact-check pass against our product records. How we write.