gpt4 book ai didi

yarnpkg - yarn 2 : how to run a script from the `node_modules/.bin` directory?

转载 作者:行者123 更新时间:2023-12-05 04:43:37 25 4
gpt4 key购买 nike

如何使用 Yarn 2 从 node_modules/.bin 目录运行脚本?

示例

假设我需要运行位于该目录中的“eslint”脚本

node_modules
├── .bin
│ ├── eslint

使用 NPM,我只需运行 npx eslint 即可运行可执行文件。我如何使用 Yarn 2 实现这一目标?

最佳答案

它和经典 Yarn 中的一样,运行这个:

yarn eslint

引用:https://yarnpkg.com/cli/run#details

This command will run a tool. The exact tool that will be executed will depend on the current state of your workspace:

  • If the scripts field from your local package.json contains a matching script name, its definition will get executed.

  • Otherwise, if one of the local workspace's dependencies exposes a binary with a matching name, this binary will get executed.

  • Otherwise, if the specified name contains a colon character and if one of the workspaces in the project contains exactly one script with a matching name, then this script will get executed.

如果您想忽略任何用户定义的脚本并只检查二进制文件,您可以传递 -B option .


还有yarn exec :

yarn exec eslint

关于yarnpkg - yarn 2 : how to run a script from the `node_modules/.bin` directory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69586166/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com