laravel 如何更改 Yarn 默认包目录?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40488421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change Yarn default packages directory?
提问by Mladen Janjetovic
When Yarn is used to install dependencies, it puts them in node-modules
directory by default.
当使用 Yarn 安装依赖项时,它node-modules
默认将它们放在目录中。
How can I change this to i.e Laravel resources
folder?
Like .bowerrc
is used for bower to set "directory": "resources/assets"
如何将其更改为 ie Laravelresources
文件夹?
Like.bowerrc
用于 bower 设置"directory": "resources/assets"
回答by user2977243
yarn install --modules-folder ./resources
UPDATE:Keep an eye on this GitHub Issueas this feature is not quite stable.
更新:请密切关注此 GitHub问题,因为此功能不太稳定。
UPDATE 2:From Damien'sanswer below, you can add --install.modules-folder "./resources"
to a .yarnrc
fileso that you don't need to continually pass the commandline argument in for each subsequent invocation. Note that double quotes are required; without those, you will get an Invalid value type 1:25
or similar error.
更新 2:从下面Damien 的回答中,您可以添加--install.modules-folder "./resources"
到.yarnrc
文件中,这样您就不需要为每个后续调用不断传递命令行参数。注意双引号是必需的;没有这些,你会得到一个Invalid value type 1:25
或类似的错误。
You can then commit the .yarnrc
to source control so that other developers on the project can use the same settings automatically.
然后,您可以将其提交.yarnrc
到源代码管理,以便项目中的其他开发人员可以自动使用相同的设置。
回答by Saint
You can create a .yarnrcfile with the following content:
您可以创建一个包含以下内容的.yarnrc文件:
--modules-folder resources
This way every yarn
command will have this parameter set.
这样每个yarn
命令都会有这个参数集。
回答by Saumya Rastogi
According to Yarn Docs, you can specify directories in package.json
file
根据Yarn Docs,您可以在package.json
文件中指定目录
{
"directories": {
"lib": "path/to/lib/",
"bin": "path/to/bin/",
"man": "path/to/man/",
"doc": "path/to/doc/",
"example": "path/to/example/"
}
}
When installing your package, you can specify exact locations to put binary files, man pages, documentation, examples, etc.
安装包时,您可以指定放置二进制文件、手册页、文档、示例等的确切位置。