npm run在哪里寻找脚本? [英] Where is npm run looking for the scripts?

查看:226
本文介绍了npm run在哪里寻找脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在命令行中键入"npm run test"时,npm转到package.json,转到脚本"部分,并尝试在那里匹配测试". 到目前为止一切顺利.

When I type "npm run test" in the command line, npm goes to package.json, to the "scripts" section and tries to match "test" there. So far so good.

现在,"test"后面的行如下:"JASMINE_CONFIG_PATH=./spec/support/jasmine.json jasmine-run",但是可以除去第一部分(茉莉花运行"以外的所有内容),而不会出现问题. [我有一个结构类似的项目,可以在其中测试这些修改]

Now, the line behind "test" is the following: "JASMINE_CONFIG_PATH=./spec/support/jasmine.json jasmine-run" but the first part (everything except "jasmine-run") can be removed witout problems. [I have a similarily structured project where it works, so I can test these modifications]

现在: npm在哪里寻找茉莉花"?

now: WHERE is npm looking for "jasmine-run" ???

因为我有一个脚本可以工作的项目,所以我可以寻找它,但是答案是:在package.json旁边的node_modules文件夹中是一个模块,在package.json所在的模块中,"bin "部分:

Because since I have a project where the script provided work, I could look for it, but the answer is: in the node_modules folder next to package.json is a module, in whose package.json has, in the "bin" section:

"jasmine-run": "tools/jasmine-run/jasmine-run.js",

但是,这两个项目中都存在这种精确的设置.在一种方法中一切正常,而在另一种茉莉花润"中则找不到.

However, this exact setup exists in both projects. and in one everything works, while in the other "jasmine-run" cannot be found.

作为答案的替代,我还将对npm运行实际如何/在何处寻找其内容进行适当的解释(或消息出处),因为那样的话,我自己可能会发现错误.

As ana lternative to an answer I'd also take a proper explanation (or source) on how/where npm run actually looks for its stuff, because then I could probably find the error myself.

推荐答案

使用npm运行脚本,如:

When you run a script with npm like :

npm run-script <name>

或带有

npm test or npm start, 

您当前软件包目录的bin目录位于路径的前面. 对于您来说,在许多情况下 ./node_modules/.bin/, 包含指向程序包的可执行脚本的链接.

your current package directory's bin directory is placed at the front of your path. For your and in many of the cases will probably be ./node_modules/.bin/, which contains a link to your package's executable scripts.

无论如何,这里都有所有有关npm运行方式的解释: https://docs.npmjs .com/cli/run-script

Anyway you have all the explanation how npm runs work here : https://docs.npmjs.com/cli/run-script

这篇关于npm run在哪里寻找脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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