lerna publish with prepublishOnly executes in leaf
See original GitHub issueWhen running lerna publish
, it fails at prepublishOnly
script as it runs on the leaf only instead from root.
Expected Behavior
lerna publish
should run prepublishOnly
script from root similar to lerna exec --scope <component> npm publish
Current Behavior
It fails at prepublishOnly
script as it requires some binaries linking and we use lerna bootstrap --nohoist
which doesn’t creates any .bin
files like in lerna@2version
.
And hence it fails
package.json
"scripts": {
"prepublishOnly": "npm run build",
"build": "npm run build:clean && npm run build:lib",
"build:clean": "rimraf lib",
"build:lib": "webpack"
}
Error
> rimraf lib
sh: rimraf: command not found
The rmraf
exist in the root node_modules
but not in the leaf.
cmd (here lerna
is an external command)
lerna publish
but following run as expected when running through the script
lerna publish --cd-version=prerelease --force-publish=* --no-verify-access
Possible Solution
Steps to Reproduce (for bugs)
lerna.json
<!-- Please paste your `lerna.json` here -->
lerna-debug.log
<!-- If you have a `lerna-debug.log` available, please paste it here -->
<!-- Otherwise, feel free to delete this <details> block -->
Context
Your Environment
Executable | Version |
---|---|
lerna --version |
3.13.0 |
npm --version |
VERSION |
yarn --version |
VERSION |
node --version |
VERSION |
OS | Version |
---|---|
NAME | VERSION |
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
@lerna/publish | Yarn - Package Manager
When you run the new command lerna repair , lerna will execute a series of code migrations/codemods which update your workspace to the...
Read more >Lerna: Documentation
Lerna is a fast modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
Read more >How to npm publish specific folder but as package root
now when you run publish command npm involve prepublishOnly . It builds files and saves them to lib folder (a build script depend...
Read more >JavaScript @lerna/run-lifecycle getOrderedCalls Examples
it("does not duplicate rooted leaf scripts", async () => { const cwd = await initFixture("lifecycle-rooted-leaf"); await lernaPublish(cwd)(); ...
Read more >How to set up a TypeScript monorepo and make Go ... - Medium
Firstly, when publishing a single package (with independent versioning), lerna won't run the prepublishOnly script for its dependencies.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I mean my issue was, the
lerna
doing differently when we runlerna
command externally. For example (works fine):package.json
Which runs publish script in all the packages as expected and we don’t get any errors.
But when we ran through the external command like (here
lerna
was from global npm package)lerna version --conventional-commits && lerna publish from-package --conventional-commits
It fails with the following error.
I understand, in leaf nodes, we need dev dependency on
rimraf
but I was expecting it would run from the root in both cases. Maybe I’m missing something here as I’m curious to find why it runs through the scripts without error otherwise not.Don’t use a global installation of
lerna
, only use a local install in the rootdevDependencies
.npx lerna
if you must run the commands outside of npm scripts.