Skip to content

[BUG] Unexpected behavior with publish dry-run #4398

Description

@FStefanni

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Hi,

  1. npm publish --dry-run calls the package.json script "prepublishOnly"
  2. "prepublishOnly" executes a bash script: ./prepublish.sh
  3. ./prepublish.sh does the following:
#!/bin/bash
rm -fr node_modules
npm install .
npm run build
  1. The ./prepublish.sh fails, not finding tsc, and actually the node_modules directory is missing!

So it seems to me that somehow the npm commands run by the ./prepublish.sh script inherits the "--dry-run" option.
Is this the expected behavior?
IMHO it should be not, and older versions did work properly as far as I remember.
Or, at least, there should be an option to not inherit dry-run behavior.

Please note that if I run the ./prepublish.sh script, it works fine. This behavior happens only when running npm publish --dry-run.

Regards

Expected Behavior

npm commands should perform what explicitly told to do.
Or there should be a way to perform the install-and-build check performed by my script.

Steps To Reproduce

Already posted before

Environment

  • npm: 8.4.1
  • Node.js: 17.1.0
  • OS Name: Linux
  • System Model Name: Debian Testing

Activity

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

    Bugthing that needs fixingPriority 2secondary priority issueRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions