Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepublishOnly runs when installing packages from git #7026

Closed
2 of 4 tasks
SystemParadox opened this issue Sep 1, 2023 · 1 comment · Fixed by #7096
Closed
2 of 4 tasks

prepublishOnly runs when installing packages from git #7026

SystemParadox opened this issue Sep 1, 2023 · 1 comment · Fixed by #7096
Assignees

Comments

@SystemParadox
Copy link

SystemParadox commented Sep 1, 2023

Verify latest release

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

pnpm version

8.7.1

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

Hooks

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

No response

Reproduction steps

  • Create package foo with a prepublishOnly script and push to github
  • Create a package and pnpm i github:foobar/foo

Describe the Bug

When installing from git/github pnpm runs the prepublishOnly script. This will almost certainly fail.

In #5876 (comment) @zkochan posted this:

If you have a git-hosted dependency then it needs to be built. I don't think this can be changed. All we can do is to throw an exception if there is a git-hosted dependency that needs to be built and ignore-scripts is used.

This is absolutely incorrect. See npm/npm#10074. The entire purpose of prepublishOnly existing (rather than prepublish) is to not do this. What you are looking for is prepare.

See https://docs.npmjs.com/cli/v9/using-npm/scripts:

prepare

  • Runs BEFORE the package is packed, i.e. during npm publish and npm pack
  • Runs on local npm install without any arguments
  • NOTE: If a package being installed through git contains a prepare script, its dependencies and devDependencies will be installed, and the prepare script will be run, before the package is packaged and installed.

prepublishOnly

  • Runs BEFORE the package is prepared and packed, ONLY on npm publish.

Expected Behavior

prepublishOnly should NEVER, EVER be run on any kind of install. It should only be run if the user is actually publishing.

Which Node.js version are you using?

16.20.1

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)

Debian 11

@SystemParadox
Copy link
Author

@zkochan thank you very much for the speedy response!

phlmn added a commit to bugbakery/slate-automerge-doc that referenced this issue Dec 28, 2023
which did just work due to a npm bug (pnpm/pnpm#7026)
TV-T added a commit to TV-T/postgres-migrations that referenced this issue Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants