别名(Aliases)
别名让您可以使用自定义名称安装软件包。
Let's assume you use lodash
all over your project. There is a bug in lodash
that breaks your project. You have a fix but lodash
won't merge it. Normally
you would either install lodash
from your fork directly (as a git-hosted
dependency) or publish it with a different name. If you use the second solution
you have to replace all the requires in your project with the new dependency
name (require('lodash')
=> require('awesome-lodash')
). 有了别名,你可以有第三种解决方式。
Publish a new package called awesome-lodash
and install it using lodash
as
its alias:
pnpm add lodash@npm:awesome-lodash