Skip to content

np fails instantly if pack script fails #780

@fregante

Description

@fregante

Description

I tried running np on a fresh repo pull (no npm install yet) and it failed because I had a pack npm script.

Note that this is an uncaught error from an internal np command, not during the final pack phase.

The strange part is that np already calls npm pack with --foreground-scripts=false

❯ np

✖ ExecaError: Command failed with exit code 2: npm pack --dry-run --json --silent '--foreground-scripts=false'

{
  "error": {
    "code": 2,
    "summary": "command failed",
    "detail": "sh -c tsc --sourceMap false\nerror TS2318: Cannot find global type 'Array'.\nerror TS2318: Cannot find global type 'Boolean'.\nerror TS2318:

Steps to reproduce

On any repo:

  1. npm pkg set scripts.pack='exit 1'
  2. np

Expected behavior

It's not clear what the behavior should be. I think np is calling pack to get the list of "new files", but when it does so it expects the repo to be prepped in some way (npm pack should already work).

Given that np runs npm install internally, I'd think it wouldn't need npm install also before running.

Possible fixes

  • make sure npm scripts do not run during this phase
  • catch and handle the error properly

Environment

np - 11.0.2
Node.js - 22.18.0.
npm - 10.9.3
Git - 2.39.5 (Apple Git-154)
OS - macOS 15.7.3

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