如何运行“ npm命令”而不运行“ run”(即“ npm command”而不是“ npm run command”?)
我的package.json
定义:
...
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"debug": "node --inspect-brk=9229 scripts/start.js"
},
...
npm start
和npm test
都分别用作npm run start
和npm run test
。但是,npm build
不会:
$ npm build
npm WARN build `npm build` called with no arguments. Did you mean to `npm run-script build`?
我需要将run
放在npm
和build
之间,即npm run build
。
npm debug
也是一样,尽管输出不同于npm build
的输出:
$ npm debug
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
当然,这似乎是因为start
和test
都属于where <command> is one of:
列表。
但是我想知道,有没有一种方法可以告诉npm
仅使用command
/npm build
/ npm debug
运行npm my_command
或npm build
甚至是npm debug
这样的任意npm my_command
?
这只是我的好奇心,这就是为什么我要问。
谢谢您的关注。
回答如下:非常抱歉,但是不可能直接:(
我想,您可以克隆npm存储库并添加您自己的脚本。
之后,您将可以像npm my_awesome_command
一样启动它>
如何运行“ npm命令”而不运行“ run”(即“ npm command”而不是“ npm run command”?)
我的package.json
定义:
...
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"debug": "node --inspect-brk=9229 scripts/start.js"
},
...
npm start
和npm test
都分别用作npm run start
和npm run test
。但是,npm build
不会:
$ npm build
npm WARN build `npm build` called with no arguments. Did you mean to `npm run-script build`?
我需要将run
放在npm
和build
之间,即npm run build
。
npm debug
也是一样,尽管输出不同于npm build
的输出:
$ npm debug
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
当然,这似乎是因为start
和test
都属于where <command> is one of:
列表。
但是我想知道,有没有一种方法可以告诉npm
仅使用command
/npm build
/ npm debug
运行npm my_command
或npm build
甚至是npm debug
这样的任意npm my_command
?
这只是我的好奇心,这就是为什么我要问。
谢谢您的关注。
回答如下:非常抱歉,但是不可能直接:(
我想,您可以克隆npm存储库并添加您自己的脚本。
之后,您将可以像npm my_awesome_command
一样启动它>