Resources:
How to Use
Here are the commands I needed to learn ASAP:
- Initial Run:
yalc publish
in source package,yalc add {packageName}
where testing / in consumer- Use
yalc link {packageName}
for symlink version, which does not modifypackage.json
- Use
--dev
for devDependency, with eitheradd
orlink
- 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 --files
runs 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
--changed
flag withpublish
orpush
is 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
yarn
ornpm install
after linking a new package that contributesbin
entries? You can also use--npm
or--yarn
with yalc publish commands to trigger this.
- Did you make sure to run
- Issues with
Cannot find module ____
- Try deleting your
yarn.lock
orpackage-lock.json
file and then runningyarn
ornpm install
again - 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_modules
combined withyalc remove
andyalc add
for a full reset
- You might have a corrupted node_modules setup; try
- Yalc doesn't seem to be respecting package.json
files
option- Make sure you haven't mixed up
./{dir}
and/{dir}
- you should be using the second version. This is true fornpm
as well.
- Make sure you haven't mixed up