Skip to content

preprepare behavior does not match npm #8987

@benmccann

Description

@benmccann

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

9.15.4

Which area(s) of pnpm are affected? (leave empty if unsure)

Package manager compatibility

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

Create a package.json with a preprepare script that prints when it runs.

{
	"name": "myapp2",
	"private": true,
	"version": "0.0.1",
	"type": "module",
	"scripts": {
		"preprepare": "echo 'running preprepare'"
	}
}

If you do an npm install you will see that preprepare is run. If you do a pnpm install you will see that preprepare is not run

Describe the Bug

preprepare is not run on install on pnpm, but is on npm

Expected Behavior

Match npm's behavior of running prepare if and only if install or ci is run

npm's behavior can be seen both in the provided reproduction and in the npm docs: https://docs.npmjs.com/cli/v10/using-npm/scripts#life-cycle-operation-order

Motivation

I wanted to replace SvelteKit's postinstall script with a preprepare script in order to better support pnpm 10 (sveltejs/cli#388 / sveltejs/cli#409)

Which Node.js version are you using?

22.11.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions