Resources:
How to Use
Here are the commands I needed to learn ASAP:
- Initial Run:
yalc publishin source package,yalc add {packageName}where testing / in consumer- Use
yalc link {packageName}for symlink version, which does not modifypackage.json - Use
--devfor devDependency, with eitheraddorlink
- Updating:
- Run
yalc publish --push(or justyalc push) in source package to distribute updates wherever it is used - If files seem to get stuck, you can try:
yalc push --replace- In testing:
yalc remove {packageName} && yalc add {packageName}
- Run
Fun Tips
yalc publish --filesruns faster for me thannpm publish --dry-run(this is to get a tarball / publish preview of what files would end up on NPM)
Watching for Changes
Currently, Yalc does not have a built-in way to watch for changes and relink / republish on source code updates.
The
--changedflag withpublishorpushis to avoid redundant relinking when files have not changed. It does not watch anything.
However, there are some workarounds. The one I have personally tried is using nodemon as the watcher.
For example, here is how you could set up nodemon to run yalc push with a TypeScript package that compiles to /dist:
{
"scripts": {
"watch": "nodemon -e js,ts --ignore dist --exec \"tsc --sourceMap && yalc push --changed\""
}
}Troubleshooting
- Issues using
bin,command not found, etc.- Did you make sure to run
yarnornpm installafter linking a new package that contributesbinentries? You can also use--npmor--yarnwith yalc publish commands to trigger this.
- Did you make sure to run
- Issues with
Cannot find module ____- Try deleting your
yarn.lockorpackage-lock.jsonfile and then runningyarnornpm installagain - Check your lockfile (and/or
node_modules) to verify the dependency is getting pulled in
- Try deleting your
- Issues with
UnhandledPromiseRejectionWarning: Error: EEXIST: file already exists, symlink ...- You might have a corrupted node_modules setup; try
rm -rf node_modulescombined withyalc removeandyalc addfor a full reset
- You might have a corrupted node_modules setup; try
- Yalc doesn't seem to be respecting package.json
filesoption- Make sure you haven't mixed up
./{dir}and/{dir}- you should be using the second version. This is true fornpmas well.
- Make sure you haven't mixed up