当依赖不是全局的时候运行package.json依赖 [英] Running package.json dependencies when dependencies are not global

查看:209
本文介绍了当依赖不是全局的时候运行package.json依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含rimraf的package.json作为它的依赖项。 rimraf不是全球安装的。从命令提示符下,我可以输入什么命令来运行rimraf?像npm run-command rimraf?

解决方案

您会运行

  ./ node_modules / .bin / rimraf 

或者如果它是一些常见任务, d将它添加到你的 package.json中

 scripts: {
clean:rimraf ...
}

和然后调用 npm run clean 脚本中的命令会自动使用 ./ node_modules / .bin 解析。


Let's say I have a package.json with "rimraf" as a dependency in it. "rimraf" is not installed globally. What command, from the command prompt, can I enter to run "rimraf"? Something like "npm run-command rimraf?"

解决方案

You'd run

./node_modules/.bin/rimraf

or if it is some common task, I'd add it to your package.json:

"scripts": {
    "clean": "rimraf ..."
}

and then call npm run clean. Commands in scripts automatically resolve with ./node_modules/.bin.

这篇关于当依赖不是全局的时候运行package.json依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆