Yarn 包括一个可选的 "Plug'n'Play" feature移动node_modules
出项目目录。这样做会创建一个 .pnp.js
文件,其中包含对硬盘驱动器上各种依赖路径的引用。
该文件是自动生成的,有几千行长,并且似乎引用了特定于运行 yarn install
的机器的路径。 .
是 .pnp.js
意味着与其余代码一起提交?尽管该文件似乎无法提交,但我似乎找不到任何有关此的信息。什么是公认的最佳实践,为什么?
最佳答案
我找到了this comment by Arcanis (Yarn 的主要维护者)关于在 .gitignore
中包含什么内容的问题.它可能会回答你的问题:
.yarn/plugins
and.yarn/releases
contain the Yarn releases used in the current repository (as defined byyarn set version
). You will want to keep them versioned (this prevents potential issues if, say, two engineers use different Yarn versions with different features).
.yarn/unplugged
should likely always be ignored, since it may contain native builds
.yarn/build-state.yml
should likely be ignored as well, as it contains the build infos
- If for some reason you version
unplugged
, it may make sense to keepbuild-state
as well
.yarn/cache
may be ignored, but you'll need to runyarn install
to regenerate it
- Versioning it unlocks what we call Zero-Installs - it's optional, though
.pnp.js
(and potentially.pnp.data.json
) are in the same boat as the cache. Add it to your repository if you keep your cache in your repository, and ignore it otherwise.
yarn.lock
should always be stored within your repository (even if you develop a library)So to summarize:
If you're using Zero-Installs:
.yarn/unplugged .yarn/build-state.yml
If you're not using Zero-Installs:
.yarn/* !.yarn/releases !.yarn/plugins .pnp.*
关于javascript - 我是否打算提交 yarn 的 `.pnp.js` 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58550439/