【问题标题】:How does yarn find a module installed as a dev-dependencyyarn 如何找到作为开发依赖项安装的模块
【发布时间】:2021-02-26 13:57:52
【问题描述】:

package.json 文件中的脚本对象是 Gulp 或类似构建工具的现代替代品。假设 Vuepress 使用yarn add -D vuepress 安装(意味着 vuepress 安装在本地的 node_modules 文件夹中。

进一步,假设 package.json 文件包含以下脚本对象:

"scripts": {
    "docs:dev": "vuepress dev docs",
    "docs:build": "vuepress build docs"
  }

终端中执行的命令yarn docs:dev如何解析vuepress对象?类似的调用通常会导致错误vuepress not recognized ...

附:因为我在路径环境变量中没有vuepress,所以唯一可以解决它的地方是根级node_modules文件夹。

【问题讨论】:

    标签: yarnpkg package.json vuepress


    【解决方案1】:

    我猜对了——npm 和 yarn(从终端调用)都能够检查所有环境变量,以及搜索文件夹 node_modules。在我的具体示例中,运行命令

    npm run env | grep scripts
    

    结果

    npm_config_ignore_scripts=
    npm_config_scripts_prepend_node_path=warn-only
    npm_package_scripts_docs_build=vuepress build docs
    npm_package_scripts_docs_dev=vuepress dev docs
    npm_package_scripts_env=env
    

    文章https://techsparx.com/nodejs/tools/npm-build-scripts.html有更多信息

    【讨论】:

      猜你喜欢
      • 2022-01-07
      • 2021-06-23
      • 1970-01-01
      • 2019-12-03
      • 2018-12-27
      • 2018-10-28
      • 2022-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多