当前位置: 首页 > news >正文

mac电脑安装 nvm 报错如何解决

前言

已知:安装nvm成功;终端输入nvm -v 有版本返回

1. 启动全局配置环境变量失败

source ~/.zshrc~ 

返回:

source: no such file or directory: /Users/你的用户名/.zshrc~

2 安装node失败

nvm install 16.13

返回:

mkdir: /Users/你的用户名/.nvm/alias: Permission denied
mkdir: /Users/你的用户名/.nvm/alias: Permission denied
Downloading and installing node v16.13.2...
mkdir: /Users/你的用户名/.nvm/.cache: Permission denied
creating directory /Users/你的用户名/.nvm/.cache/bin/node-v16.13.2-darwin-arm64/files failed
Downloading https://nodejs.org/dist/v16.13.2/node-v16.13.2-darwin-arm64.tar.xz...
Warning: Failed to create the file                                             
Warning: /Users/你的用户名/.nvm/.cache/bin/node-v16.13.2-darwin-arm64/node-v16.13.
Warning: 2-darwin-arm64.tar.xz: No such file or directory0.0%curl: (23) Failure writing output to destinationdownload from https://nodejs.org/dist/v16.13.2/node-v16.13.2-darwin-arm64.tar.xz failed
grep: /Users/你的用户名/.nvm/.cache/bin/node-v16.13.2-darwin-arm64/node-v16.13.2-darwin-arm64.tar.xz: No such file or directory
Provided file to checksum does not exist.
Binary download failed, trying source.
Detected that you have 8 CPU core(s)
Running with 7 threads to speed up the build
Clang v3.5+ detected! CC or CXX not specified, will use Clang as C/C++ compiler!
mkdir: /Users/你的用户名/.nvm/.cache: Permission denied
creating directory /Users/你的用户名/.nvm/.cache/src/node-v16.13.2/files failed
Downloading https://nodejs.org/dist/v16.13.2/node-v16.13.2.tar.xz...
Warning: Failed to create the file                                             
Warning: /Users/你的用户名/.nvm/.cache/src/node-v16.13.2/node-v16.13.2.tar.xz: No 
Warning: such file or directory0.0%curl: (23) Failure writing output to destinationdownload from https://nodejs.org/dist/v16.13.2/node-v16.13.2.tar.xz failed
grep: /Users/你的用户名/.nvm/.cache/src/node-v16.13.2/node-v16.13.2.tar.xz: No such file or directory
Provided file to checksum does not exist.

3 查看全局变量,没有看到配置好的nvm配置

echo $PATH  

解决

结合以上三个问题都是因为安装nvm时,没有安装好!还有权限问题。

1 修复目录权限

sudo chown -R $(whoami) ~/.nvm

2 重新安装nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

3 查看当前电脑的shell配置

echo $SHELL

可能输出是/bin/bash或者/bin/zsh

4 修改配置文件

打开配置文件

nano ~/.zshrc  # 或 nano ~/.bash_profile

在文件末尾添加

 export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # 加载 nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # 加载自动补全

5 重新启动配置文件

如果是bin/zsh,使用下面的命令:

source ~/.zshrc  

如果是/bin/bash,使用下面的命令:

 source ~/.bash_profile

6 验证nvm 和npm是否可以使用

nvm install #指定版本
nvm ls #看目前存在的版本
nvm --version  # 应显示 NVM 版本
node -v        # 应显示 Node.js 版本
npm -v         # 应显示 npm 版本
which node     # 应显示 ~/.nvm/versions/node/.../bin/node
which npm      # 应显示 ~/.nvm/versions/node/.../bin/npm

补充说明

打开/.zshrc 文件后,如何保存修改呢?

按 Ctrl + X后请添加图片描述按Y确认保存,最后按Enter键保存。


文章转载自:

http://uCHTri4z.qbnfc.cn
http://QuHzpfHo.qbnfc.cn
http://2SlMsjYI.qbnfc.cn
http://twbYPnIP.qbnfc.cn
http://9n8hk7Ur.qbnfc.cn
http://mxwo0OSO.qbnfc.cn
http://nmbeiuLv.qbnfc.cn
http://6MJKmt9v.qbnfc.cn
http://zLAaOBt1.qbnfc.cn
http://JDU2b9A3.qbnfc.cn
http://ISbodvA4.qbnfc.cn
http://VrEmttSz.qbnfc.cn
http://4x73luLX.qbnfc.cn
http://H0dp2dpY.qbnfc.cn
http://x3rt6psl.qbnfc.cn
http://uFaCczwa.qbnfc.cn
http://W2Whrnwb.qbnfc.cn
http://Lrl2CAE8.qbnfc.cn
http://QA7bw2EH.qbnfc.cn
http://eAyjNhhW.qbnfc.cn
http://hd53XnGT.qbnfc.cn
http://tw3w3vdt.qbnfc.cn
http://TeCMnna0.qbnfc.cn
http://E2rQf2fw.qbnfc.cn
http://ZpulaG3F.qbnfc.cn
http://URTj5yYb.qbnfc.cn
http://n6STso37.qbnfc.cn
http://cabtYREl.qbnfc.cn
http://Nqv3bbRq.qbnfc.cn
http://T68wNFxV.qbnfc.cn
http://www.dtcms.com/a/227100.html

相关文章:

  • 前端自动化测试利器:Playwright 全面介绍
  • Python-120:摇骰子的胜利概率
  • 23. Merge k Sorted Lists
  • 鸿蒙进阶——Mindspore Lite AI框架源码解读之模型加载详解(一)
  • DAY41 CNN
  • DAY 41 简单CNN
  • Python----目标检测(训练YOLOV8网络)
  • SpringBoot手动实现流式输出方案整理以及SSE规范输出详解
  • JavaSE知识总结(集合篇) ~个人笔记以及不断思考~持续更新
  • 学习经验分享【40】目标检测热力图制作
  • [HTML5]快速掌握canvas
  • (Python网络爬虫);抓取B站404页面小漫画
  • 智慧零工平台前端开发实战:从uni-app到跨平台应用
  • uniapp路由跳转toolbar页面
  • 通俗易懂解析:@ComponentScan 与 @MapperScan 的异同与用法
  • Java连接Redis和基础操作命令
  • 微软markitdown PDF/WORD/HTML文档转Markdown格式软件整合包下载
  • GODOT引擎学习日志
  • Gartner《Emerging Patterns for Building LLM-Based AIAgents》学习心得
  • 线程间和进程间是如何进行通信
  • 复变函数 $w = z^2$ 的映射图像演示
  • 端到端的导航技术NeuPAN论文讲解
  • 《AI Agent项目开发实战》DeepSeek R1模型蒸馏入门实战
  • 达梦数据库 Windows 系统安装教程
  • HTML 中 class 属性介绍、用法
  • 【学习笔记】On the Biology of a Large Language Model
  • ffmpeg 的视频格式转换 c# win10
  • 使用免费wordpress成品网站模板需要注意点什么
  • 【SpringBoot】| 接口架构风格—RESTful
  • opencv调用模型