简体   繁体   English

NPM如何运行不在路径中的命令

[英]How can NPM run a command that isn't in path

The ava command is not in my path. ava命令不在我的路径中。 I can not run it from in the project directory that contains some AVA tests. 我无法在包含某些AVA测试的项目目录中运行它。

My npm test command of my project is set to ava tests/*.js --verbose , and can somehow call the ava command from the same location in the terminal. 我将项目的npm test命令设置为ava tests/*.js --verbose ,并且可以通过某种方式从终端的同一位置调用ava命令。

My questions is: how is npm calling the ava command? 我的问题是:npm如何调用ava命令? I suspect it is calling it from the project's node_modules folder, but I could not find it in any source. 我怀疑它是从项目的node_modules文件夹中调用它的,但是在任何源中都找不到它。

If anyone can explain how this happens, or better yet show me the source, I would really appreciate it. 如果有人可以解释这种情况是如何发生的,或者更好地向我展示消息来源,我将不胜感激。

当您运行npm run [script]或本例中的npm test ,NPM非常聪明,可以尝试首先从node_modules/.bin目录执行二进制文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM