最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

如何运行“ npm命令”而不运行“ run”(即“ npm command”而不是“ npm run command”?)

IT培训 admin 7浏览 0评论

如何运行“ 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 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 build/ npm debug运行npm my_commandnpm 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 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 build/ npm debug运行npm my_commandnpm build甚至是npm debug这样的任意npm my_command

这只是我的好奇心,这就是为什么我要问。

谢谢您的关注。

回答如下:

非常抱歉,但是不可能直接:(

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

之后,您将可以像npm my_awesome_command一样启动它>

发布评论

评论列表 (0)

  1. 暂无评论