npm install报错:npm ERR! code 128

前端 2023-07-22 427次浏览

最近调试安装vue-element-admin,执行npm install后报如下错误信息:

npm ERR! code 128
npm ERR! git dep preparation failed
npm ERR! command /Users/robin/.nvm/versions/node/v20.5.0/bin/node /Users/robin/.nvm/versions/node/v20.5.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/Users/robin/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm ERR! code 128
npm ERR! npm ERR! An unknown git error occurred
npm ERR! npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/adobe-webplatform/eve.git
npm ERR! npm ERR! git@github.com: Permission denied (publickey).
npm ERR! npm ERR! fatal: Could not read from remote repository.
npm ERR! npm ERR! 
npm ERR! npm ERR! Please make sure you have the correct access rights
npm ERR! npm ERR! and the repository exists.
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in: /Users/robin/.npm/_logs/2023-07-22T14_57_16_187Z-debug-0.log

npm install报错:npm ERR! code 128

解决方法:

  1. 进入用户根目录下,打开.gitconfig文件,这里以Mac系统为例:
    vim ~/.gitconfig
  2. 添加配置信息
    • sslverify = false
    • [url ""]根据自己的报错信息填写,我上面报错是拉取git文件ssh://git@github.com/adobe-webplatform/eve.git 报错,下面是具体修改示例:
      [http]
      sslverify = false
      [url "https://git@github.com/adobe-webplatform/eve.git"]
      insteadOf = git@github.com/adobe-webplatform/eve.git
  3. 配置修改保存退出后,执行命令
    npm config delete proxy
  4. 再次运行npm install,问题就可以解决了!
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址