question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`changeset publish` and `changeset version` do not run package.json `prepublish` or `version` scripts

See original GitHub issue

Thanks for your work on this.

NPM lifecycle scripts do not seem to work. When I run a command like changeset publish on a repo using yarn workspaces, I’m not seeing any prepublish scripts run. When I do yarn workspace <workspace_name> exec npm publish, the prepublish scripts run as usual.

Affected Packages

@changesets/cli https://github.com/changesets/changesets/tree/main/packages/cli/src/commands/publish

Problem

Running changeset publish or changeset version does not trigger any npm lifecycle scripts.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
awxalbertcommented, Nov 16, 2022

Run into the same problem, not sure if we’re in the same context when running the script, but after some digging, I found the problem probably related to run changeset publish in CI system like gitlab CI. So in general, npm will not execute lifecycle hooks when it’s executed in root role. (in early npm versions before npm@7 ?), so maybe that’s why it worked in the local. It’s not a problem for changeset, just post the results here so anybody can reference this in the future.

related topics:

potential solutions:

  • set unsafe-perm to true
  • just run yarn build before publish
0reactions
Andaristcommented, Jul 2, 2022

Hm, I’ve just tested with npm 6 in your repo and I still get the same result.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating git tags fails · Issue #196 · changesets ... - GitHub
When running yarn changeset publish (on Debian) I get this error: ... info @undataforum/tokens is being published because our local version ...
Read more >
How to detect when `prepublish` script is executed as a result ...
I want my script to execute only in case of user executing npm publish . However, NPM will execute "prepublish" script if user...
Read more >
@changesets/cli - npm
Organise your package versioning and publishing to make both contributors and maintainers happy. Latest version: 2.25.2, last published: 25 ...
Read more >
Creating a Yarn Monorepo in 2022 - Heygrady
This step will install Yarn Berry, create a package.json pre-configured ... "yarn build && changeset publish", "version": "changeset version ...
Read more >
publish-police - NPM Package Overview - Socket - Socket.dev
check npm dist before publish. Version: 0.0.3 was published by qidanta. ... { "ci:publish": "pnpm run build && publish-police && pnpm changeset publish",...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found