这是我所做的。查看最后一行以了解错误:
cb-machan@cb-machan bin % npm i redoc-cli
> [email protected] postinstall /usr/local/bin/node_modules/styled-components
> node ./scripts/postinstall.js || exit 0
Use styled-components at work? Consider supporting our development efforts at https://opencollective.com/styled-components
npm WARN saveError ENOENT: no such file or directory, open '/usr/local/bin/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/usr/local/bin/package.json'
npm WARN bin No description
npm WARN bin No repository field.
npm WARN bin No README data
npm WARN bin No license field.
+ [email protected]
added 309 packages from 211 contributors and audited 1381 packages in 37.029s
9 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
cb-machan@cb-machan bin % redoc-cli --help
zsh: command not found: redoc-cli
看起来我的 PATH 变量设置正确:
cb-machan@cb-machan bin % npm prefix
/usr/local/bin
cb-machan@cb-machan bin % echo $path
/usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/mysql/bin /Users/cb-machan/apache-ant-1.10.7/bin
我尝试将 shell 切换为 bash 但错误仍然存在。
答案1
看来问题在于我没有已安装redoc-cli
全球。
以下步骤修复了该问题:
- 卸载
redoc-cli
和redoc
npm uninstall redoc-cli -S
npm uninstall redoc -S
redoc-cli
全局安装
npm install redoc-cli -g