WIP: prepare script is needed for installing dependencies from git using npm #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello!
The
prepare
script is needed in a library in order to make the library installable withnpm
from a git URL in a consuming project'spackage.json
.F.e. A consuming project would have the following to install
rosbag
from git:However, there's an issue with having both
prepack
andprepare
scripts when usingnpm
:npm
will run both of them, but whennpm
runsprepack
,devDependencies
of the library being installed (f.e.devDependencies
ofrosbag
while it is being installed from git) will not be available yet, so the build will fail.The solution to make this work in
npm
is to delete theprepack
script, and just useprepare
.But here's the bad part!
Last I checked, Yarn intentionally does not run
prepare
scripts. Instead, Yarn only runsprepack
scripts, anddevDependencies
are available duringprepack
foryarn
users, so installing from git withyarn
works.Basically Yarn deviated quite significantly from
npm
here, which makes the two totally incompatible with each other when install from git.If
yarn
must be supported, then adding aprepare
script and not deleting theprepack
script won't work. In this case we would need to be sure to change the name of the package and publish it sonpm
users can install from the npm registry.If
npm
users would like to install the latest fromgit
though (while not breaking this foryarn
users), they would need to clone the project, publish it under their own name, and use apackage.json
alias: