npm:在上下文中执行?
npm: exec in context?
我想执行 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
我想执行 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 runnpm test
.)
因此,根据您的要求,您可以:
cd
到你的项目目录。然后运行以下命令:
./node_modules/.bin/vuepress eject