文件协议
file:
协议从本地路径获取包。这对于在将包发布到 npm 注册表之前在本地测试包,或者在不依赖 npm 注册表中的版本的情况下分发特定依赖非常有用。
¥The file:
protocol fetches a package from a local path. This can be useful for testing packages locally before publishing them to the npm registry, or distributing a particular dependency without relying on the version from the npm registry.
打包
¥Packing
与 git:
依赖 不同,file:
指向的文件夹在导入项目之前不会被打包。这是我们可能会在未来的主要版本中修复的问题。
¥Unlike git:
dependencies, the folder pointed to by file:
is not packed before being imported in the project. This is something we'll likely fix in a future major version.
基于文件夹的链接
¥Folder-based links
当 file:
指向文件夹时,Yarn 将复制它而不是直接引用其来源。对于 node_modules
链接器,这意味着生成的 node_modules
的内容将是唯一的文件,并且在那里执行的更改不会影响原始源文件夹。
¥When file:
points to a folder, Yarn will copy it rather than directly reference its sources. For the node_modules
linker, it means that the content of the generated node_modules
will be unique files, and that changes performed there won't affect the original source folder.
file:./relative/path/to/package.tgz
基于 Tarball 的链接
¥Tarball-based links
当 file:
指向 .tgz
文件时,Yarn 将透明地让你从存档中获取文件。对于 node_modules
链接器,这意味着存档将被解压到生成的 node_modules
文件夹中。
¥When file:
points to a .tgz
file, Yarn will transparently let you require files from within the archive. For the node_modules
linker, it means that the archive will be unpacked into the generated node_modules
folder.