Better workflow than npm | yarn link for package authors.
When developing and authoring multiple packages (private or public), you often find yourself in need of using the latest/WIP versions in other projects that you are working on in your local environment without publishing those packages to the remote registry. NPM and Yarn address this issue with a similar approach of symlinked packages (npm/yarn link
). Though this may work in many cases, it often brings nasty constraints and problems with dependency resolution, symlink interoperability between file systems, etc.
yalc
acts as very simple local repository for your locally developed packages that you want to share across your local environment.yalc publish
in the package directory, it grabs only files that should be published to NPM and puts them in a special global store (located, for example, in ~/.yalc
).yalc add my-package
in your project
it pulls package content into .yalc
in the current folder and injects a file:
/link:
dependency into package.json
. Alternatively, you may use yalc link my-package
which will create a symlink to the package content in node_modules
and will not touch package.json
(like npm/yarn link
does), or you even may use it with Pnmp/Yarn/Npm workspaces.yalc
creates a special yalc.lock
file in your project (similar to yarn.lock
and package-lock.json
) that is used to ensure consistency while performing yalc
's routines.yalc
can be used with projects where yarn
or npm
package managers are usedfor managing package.json
dependencies.Using NPM:
npm i yalc -g
Using Yarn:
yarn global add yalc
Some documented features might not have been published yet, see the change log.
yalc publish
in your dependency package my-package
.prepublish
, prepare
, prepublishOnly
, prepack
, preyalcpublish
, they will run before in this order. If your package has any of these: postyalcpublish
, postpack
, publish
, postpublish
, they will run after in this order. Use --no-scripts
to publish without running scripts.yalc
calculates the hash signature of all files and, by default, adds this signature to the package manifest version
. You can disable this by using the --no-sig
option..yalcignore
to exclude files from publishing to yalc repo, for example, files like README.md, etc.--content
flag will show included files in the published packageyalc
fully supposed to emulate behavior of npm
client (npm pack
). If you have nested .yalc
folder in your package that you are going to publish with yalc
and you use package.json
files
list, it should be included there explicitly.LF
new line symbol is used in published sources; it may be needed for some packages to work correctly (for example, bin
scripts). yalc
won't convert line endings for you (because npm
and yarn
won't either)..yalc
folder in published package content, you should add !.yalc
line to .npmignore
.workspace:
protocol in dependencies, to omit this use -no-workspace-resolve
flagyalc add my-package
in your dependent project, whichwill copy the current version from the store to your project's .yalc
folder and inject a file:.yalc/my-package
dependency into package.json
.yalc add my-package@version
. This version will be fixed in yalc.lock
and will not affect newly published versions during updates.--link
option to add a link:
dependency instead of file:
.--dev
option to add yalc package to dev dependencies.--pure
flag it will not touch package.json
file, nor it will touch modules folder, this is useful for example when working with Yarn workspaces (read below in Advanced usage section)--workspace
(or -W
) it will add dependency with "workspace:" protocol.add
, you can use the link
command which is similar to npm/yarn link
, except that the symlink source will be not the global link directory but the local .yalc
folder of your project.yalc
copies package content to .yalc
folder it will create a symlink:project/.yalc/my-package ==> project/node_modules/my-package
. It will not touch package.json
in this case.yalc update my-package
to update the latest version from store.yalc update
to update all the packages found in yalc.lock
.preyalc
and postyalc
scripts will be executed in target package on add/update operations which are performed while push
scripts
on update of particular package use (pre|post)yalc.package-name
name for script in your package.json
.--update
(--upgrade
, --up
) to run package managers's update command for packages.yalc remove my-package
, it will remove package info from package.json
and yalc.lock
yalc remove --all
to remove all packages from project.yalc installations clean my-package
to unpublish a package published with yalc publish
yalc installations show my-package
to show all packages to which my-package
has been installed.yalc add|link|update
, the project's package locations are tracked and saved, so yalc
knows where each package in the store is being used in your local environment.yalc publish --push
will publish your package to the store and propagate all changes to existing yalc
package installations (this will actually do update
operation on the location).yalc push
- is a use shortcut command for push operation (which will likely become your primarily used command for publication):scripts
options is false
by default, so it won't run pre/post
scripts (may change this with passing --scripts
flag).--changed
flag yalc will first check if package content has changed before publishing and pushing, it is a quick operation and may be useful for file watching scenarios with pushing on changes.--replace
option to force replacement of package content.preyalc
and postyalc
(read in update
docs) to execute needed script on every push.--update
to run yarn/npm/pnpm update
command for pushed packages.yalc'ed
modules temporarily during development, first add .yalc
and yalc.lock
to .gitignore
.yalc link
, that won't touch package.json
yalc add
it will change package.json
, and ads file:
/link:
dependencies, if you may want to use yalc check
in the precommit hook which will check package.json for yalc'ed
dependencies and exits with an error if you forgot to remove them.yalc'ed
stuff within the projects you are working on and treat it as a part of the project's codebase. This may really simplify management and usage of shared work in progress packages within your projects and help to make things consistent. So, then just do it, keep .yalc
folder and yalc.lock
in git.README
, LICENCE
etc. will be included also, so you may want to exclude them in .gitignore
with a line like **/.yalc/**/*.md
or you may use .yalcignore
not to include those files in package content.yalc publish some-project
will perform publish operation in the ./some-project
directory relative to process.cwd()
yalc retreat [--all]
for example before package publication to remote registry.yalc restore
.Use if you will try to add
repo in workspaces
enabled package, --pure
option will be used by default, so package.json
and modules folder will not be touched.
Then you add yalc'ed package folder to workspaces
in package.json
(you may just add .yalc/*
and .yalc/@*/*
patterns). While update
(or push
) operation, packages content will be updated automatically and yarn
will care about everything else.
If you want to override default pure behavior use --no-pure
flag.
yalc installations clean [package]
.--store-folder
flag option to override default location for storing published packages.--quiet
to fully disable output (except of errors). Use --no-colors
to disable colors.workspace-resolve=false
line to the .yalcrc
file to turn off workspace:
protocol resolution or sig=false
to disable package version hash signature.WTF.
npm link本地包做做调试流程: 安装yalc :npm install yalc -g 安装nodemon:npm install nodemon -g 1.本地宝发布:yalc publish 2.本地包package.json的scripts添加监听"watch": “nodemon --ignore dist/ --ignore node_modules/ --watch src/ -
参考链接: 【yalc 官方文档】:https://github.com/wclr/yalc 【yalc-watch 官方文档】:https://github.com/johot/yalc-watch 链接依赖库背景 以 D-SASS 前端框架为例,当我们在修改 D-SASS 前端框架时,当想着马上就要预览到修改的内容是否生效,于是在前端框架目录下进行 npm link 生成一个依赖包的软连接,然
1、输入 get-ExecutionPolicy 查看状态(Restricted 表示禁用) get-ExecutionPolicy 2、输入set-ExecutionPolicy RemoteSigned set-ExecutionPolicy RemoteSigned 报错:set-ExecutionPolicy : 对注册表项“HKEY_LOCAL_MACHINE\SOFTWARE\Mi