gpt4 book ai didi

javascript - npm:在上下文中执行?

转载 作者:行者123 更新时间:2023-12-01 16:16:42 24 4
gpt4 key购买 nike

我想执行 npm 中脚本可以执行的内容。
例如,我安装了一个 vue-press,我想执行 vuepress eject .在我的脚本中,我可以看到 vuepress可以访问,但我没有 eject 的脚本:

  "scripts": {
"dev": "vuepress dev docs",
"build": "vuepress build docs"
},
"license": "MIT",
"devDependencies": {
"vuepress": "^1.3.1",
"@vuepress/plugin-back-to-top": "^1.3.1",
"@vuepress/plugin-medium-zoom": "^1.3.1"
}
所以我可以创建一个一次性使用的脚本或使用任何命令 npm exec .我正在寻找后一种解决方案。

最佳答案

在文档中,它说明了以下关于 executables 的内容:
注:我加了粗体。

When in global mode, executables are linked into {prefix}/bin on Unix, or directly into {prefix} on Windows.

When in local mode, executables are linked into ./node_modules/.bin so that they can be made available to scripts run through npm. (For example, so that a test runner will be in the path when you run npm test.)


因此,根据您的要求,您可以:
  • cd到您的项目目录。
  • 然后运行以下命令:
    ./node_modules/.bin/vuepress eject
  • 关于javascript - npm:在上下文中执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63424195/

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