![](/img/trans.png)
[英]Unable to run npm command "Error: Command failed: npm run start"
[英]How to run “npm command” run without “run” (i.e. “npm command” instead of “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`?
我需要在npm
和build
之间放置run
,即npm run build
。
npm debug
也是如此,尽管 output 不同于 ZBB30E85411B56DC8AB44 中的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:
list。
But I was wondering, is there a way to tell npm
to run an arbitrary command
like npm build
or npm debug
or even npm my_command
just using just npm build
/ npm debug
/ npm my_command
?
这只是我的好奇心,这就是我问的原因。
感谢您的关注。
您可以改用纱线。 全局安装纱线..(在 linux 或 Mac 中)
sudo npm i -g yarn
那你可以试试。。
yarn start
看看它是否有效..在我的反应应用程序中它工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.