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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 17:34:11  来源:igfitidea点击:

How to change Yarn default packages directory?

laravelconfigyarnpkg

提问by Mladen Janjetovic

When Yarn is used to install dependencies, it puts them in node-modulesdirectory by default.

当使用 Yarn 安装依赖项时,它node-modules默认将它们放在目录中。

How can I change this to i.e Laravel resourcesfolder?
Like .bowerrcis 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 .yarnrcfileso 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:25or similar error.

更新 2:从下面Damien 的回答中,您可以添加--install.modules-folder "./resources".yarnrc文件中,这样您就不需要为每个后续调用不断传递命令行参数。注意双引号是必需的;没有这些,你会得到一个Invalid value type 1:25或类似的错误。

You can then commit the .yarnrcto 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 yarncommand will have this parameter set.

这样每个yarn命令都会有这个参数集。

回答by Saumya Rastogi

According to Yarn Docs, you can specify directories in package.jsonfile

根据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.

安装包时,您可以指定放置二进制文件、手册页、文档、示例等的确切位置。