Skip to content

"prepare" script causes npm ci to hang in CI environments #95

@cernadasjuan

Description

@cernadasjuan

Problem

When installing pdf-parse@2.4.5 as a dependency, npm ci hangs indefinitely in CI environments (e.g., GitHub Actions).

The root cause is the "prepare": "npm run build" script in package.json. The prepare lifecycle script runs automatically during npm install / npm ci for consumers of the package — not just for development. This triggers a full build (tsc, api-extractor, vite build, esbuild) which either fails silently or hangs because the build dev dependencies are not available in the published tarball.

Steps to reproduce

  1. Add pdf-parse@2.4.5 as a dependency in any project
  2. Run npm ci in a clean CI environment (e.g., GitHub Actions with ubuntu-latest)
  3. The install process hangs indefinitely at the prepare script stage

Expected behavior

npm ci should complete without running a build step, since the published package already includes pre-built files in dist/.

Workaround

Add the following to .npmrc to skip the script for this package specifically:

pdf-parse:ignore-scripts=true

This works because the published tarball already contains the compiled dist/ directory, so the prepare build is unnecessary for consumers.

Suggested fix

The prepare script should be moved to prepublishOnly so it only runs when publishing the package, not when consumers install it:

"prepublishOnly": "npm run build"

Or alternatively, remove prepare entirely and rely on a manual build step before publishing.

Environment

  • npm 10.x
  • Node.js 20.x
  • GitHub Actions (ubuntu-latest)
  • pdf-parse 2.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions