【发布时间】:2016-10-19 09:26:35
【问题描述】:
我有一个内部脚手架应用程序,为此我创建了一个yarn.lock 文件。现在,这个应用程序将被其他 Node 应用程序使用。 Yarn 在为主应用安装依赖时会考虑其依赖的锁文件吗?
【问题讨论】:
标签: yarnpkg
我有一个内部脚手架应用程序,为此我创建了一个yarn.lock 文件。现在,这个应用程序将被其他 Node 应用程序使用。 Yarn 在为主应用安装依赖时会考虑其依赖的锁文件吗?
【问题讨论】:
标签: yarnpkg
开箱即用,答案将是否。
但是有个办法。如果您看到this 讨论,则提供了使用
的建议yarn add file:path-to-submodule
在我看来,这是一种处理子模块包的更具确定性的方法。所以你可以这样做:
mkdir module && cd module
yarn init
mkdir submodule && cd submodule
yarn init // Name this package 'submodule'
yarn add express // Just an example package
rm -rf node_modules // To see if node_modules is going to be regenerated
ls // package.json yarn.lock
cd ..
yarn init
yarn add react // Another sample module
yarn add file:submodule // Adds submodule as a local dependency
yarn
cd node_modules && ls // Both react & express and their dependencies are now in module/node_modules
cd .. && cd submodule && ls // No node_modules created within /submodules
在这里你看到你已经成功地在你的主模块中创建了一个本地子模块,使用yarn add
使用这种方法的优点是:
【讨论】: