![](/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.