mac 下面使用apidoc 使用

本文详细介绍了在安装Node并遇到npm使用错误后的问题排查过程,包括修改PATH环境变量以解决找不到npm-cli.js文件的问题。同时,提供了解决使用apidoc时需要管理员权限的步骤。分享了在遇到问题时如何通过搜索引擎找到解决方案,并最终成功安装apidoc的经验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

由于很久前已经安装好了brew了,现在通过brew安装node

brew install node

安装node后使用npm的时候出现错误,错误如下

sbei215:bin alex.kong$ ./npm 
module.js:338
    throw err;
          ^
Error: Cannot find module '/usr/local/lib/node_modules/npm/bin/node_modules/npm/bin/npm-cli.js'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

通过网上查询后解决办法

修改/usr/local/lib/node_modules/npm/bin/npm文件由于npm_cli.js 位于
/usr/local/lib/node_modules/npm/bin



#!/bin/sh
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix

basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node.exe" ]; then
  "$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
else
  node "$basedir/npm-cli.js" "$@"
fi


第二步
vim ./.bash_profile

export PATH="/usr/local/lib/node_modules/npm/bin:$PATH"
export NODE_PATH="/usr/local/lib/node"

  

到了最后一步安装apidoc

npm install apidoc -g

结果又出现错误

ERR! Please try running this command again as root/Administrator.
npm ERR! Darwin 14.5.0
npm ERR! argv "node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "install" "apidoc" "-g"
npm ERR! node v0.12.4
npm ERR! npm  v2.10.1

npm ERR! Uncaught, unspecified "error" event.
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/lib/node_modules/npm/npm-debug.log

看到上面提示果断使用root执行安装,成功了

  

现在github上面的例子运行一下

apidoc example/ -o doc/

so easy

  

参考文章:

https://github.com/apidoc/apidoc

http://stackoverflow.com/questions/27824675/npm-cannot-find-npm-cli-module-after-yosemite-upgrade

http://apidocjs.com/

 

 

  

  

转载于:https://www.cnblogs.com/klj123wan/p/5455869.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值