[feature request] lerna bootstrap triggering root postinstall hook
See original GitHub issueIm not sure if this makes sense, as the intention for having root package.json
like this is unclear from the docs:
lerna-repo/
packages/
package.json
lerna.json
however its respected during the bootstraping so I think it makes sense to execute (after this line?) postinstall
script.
If you think its the right thing to do, I can provide PR for it.
Also if you provide short explanation of how combination of per package package.json
s and root package.json
should work together it would be really helpful
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
@lerna/bootstrap | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Husky - Git hooks
Modern native git hooks made easy. Husky improves your commits and more woof! You can use it to lint your commit messages, run...
Read more >How to Deploy a React Monorepo to Netlify Using Lerna and ...
GitHub Actions workflow that triggers push/pull requests to the main branch. Assuming that all deployments will come from the main branch, you ...
Read more >@lerna/bootstrap - npm
Bootstrap the packages in the current Lerna repo. Installs all of their dependencies and links any cross-dependencies. When run, this command will:.
Read more >Third Party Software 7.2 - Confluent
Apache Directory LDAP API Extras Trigger, Apache-2.0; Multi-license: ... Core functionality for the Reactor Netty library, Apache-2.0 ... exit-hook, MIT.
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 Free
Top 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
While it’s not completely clear to me if this thread wants to address the issue of having to run 2 separate commands for a locally development-ready environment or not, I wanted to contribute with the below solution.
package.json
./scripts/bootstrap.js
Any developer can do
npm install
, and the following will/should happen.npm install
runs as per usual processpostinstall
hook triggers, executing bootstrap.jsbootstrap.js
executes, which checks ifLERNA_EXECUTED
is set. If not set, doesnpm run bootstrap
npm run bootstrap
will run lerna, which (with hoisting) implies another npm install being done.postinstall
hook triggers, which again executes./scripts/bootstrap.js
bootstrap.js
will this time recognize thatLERNA_EXECUTED
is set totrue
, and will gracefully exit.LERNA_EXECUTED
will again become empty (ieecho $LERNA_EXECUTED
in the shell will return an empty string)Tested with: npm: 5.6.0 (package-lock.json-files enabled) node: 8.11.3 (LTS by current writing)
This will ease transition to lerna for me and my colleagues. Since I just discovered this, I will get back if we find any issues. The only real downside now is that you need to run a regular
npm install
before lerna does it again. On the other hand, we have listedlerna
as a local dependency, so it would not be possible for lerna to execute without the initial installation.PS. The
cross-env $npm_package_config_envs
part can be excluded (it’s a devDependency). For me it provides a neat way of accessing hoisted node_modules from my lerna packages inside thepackage.json
. This is completely unnecessary if you intend to just use thebin
’s likewebpack
for example, but really valuable if you need to access files directly inside node_modules dependencies. To not use this, just omit that part, and exclude theconfig
section altogether. If anyone knows a more intregrated way of accomplishing this, do let me know!This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.