[英]How to run locally saved npm packages without setting them on package.json?
I am trying to execute a locally saved npm package, but it is not found. 我正在尝试执行本地保存的npm程序包,但是找不到。
npm run jsdoc
Outputs: 输出:
npm ERR! Linux 4.15.0-24-generic
npm ERR! argv "/usr/bin/node" "/usr/local/bin/npm" "run" "jsdoc"
npm ERR! node v8.10.0
npm ERR! npm v3.10.10
npm ERR! missing script: jsdoc
...
But I know the script is located in my node_modules/.bin
, and can execute it directly: 但是我知道脚本位于我的
node_modules/.bin
,可以直接执行它:
jsdoc -> ../jsdoc/jsdoc.js*
And running it works as a pre-configured command on my package.json
并将其作为我
package.json
上的预配置命令package.json
"scripts": {
"doc": "jsdoc"
},
Is there a special environment configuration (npmrc or something similar) to make npm run look at both package.json
scripts and in node_modules/.bin
? 是否有特殊的环境配置(npmrc或类似的东西)使npm run既查看
package.json
脚本又node_modules/.bin
?
What am I missing? 我想念什么?
The command npm run
is an alias for npm run-script
. 命令
npm run
是npm run-script
的别名。 As seen in the docs: 如文档所示:
SYNOPSIS
npm run-script <command> [-- <args>...]
alias: npm run
It will only add node_modules/.bin
to context inside scripts edited in package.json. 它只会将
node_modules/.bin
添加到package.json中编辑的脚本内的上下文中。
The npm-run answer can be misleading as one can think npm commands could be referenced as git sub-commands would (git-init, git-clone etc), which in this particular case is a separate package, not related to npm run-script. npm-run的答案可能会产生误导,因为人们认为npm命令可以像git子命令(git-init,git-clone等)一样被引用,在这种特殊情况下,它是一个独立的软件包,与npm run-不相关。脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.