gpt4 book ai didi

node.js - 如何在没有 "npm command"的情况下运行 "run"(即 "npm command"而不是 "npm run command")?

转载 作者:太空宇宙 更新时间:2023-11-04 03:14:50 32 4
gpt4 key购买 nike

我的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 startnpm test作为npm run startnpm run test分别。然而,npm build不:

$ npm build
npm WARN build `npm build` called with no arguments. Did you mean to `npm run-script build`?

我需要输入run之间npmbuild ,即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

当然,好像是因为starttest两者都属于 where <command> is one of:列表。

但我想知道,有没有办法告诉 npm运行任意command喜欢 npm buildnpm debug甚至npm my_command只是使用 npm build/npm debug/npm my_command

这只是我的好奇心,所以我才问。

感谢您的关注。

最佳答案

很抱歉,但直接不可能:(

我想,您可以克隆 npm 存储库并添加您自己的脚本

之后您将能够像 npm my_awesome_command

一样启动它

关于node.js - 如何在没有 "npm command"的情况下运行 "run"(即 "npm command"而不是 "npm run command")?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58140282/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com