【vue3】踩坑日记,vite与node版本对应(mac环境)

创建vue3+vite+ts项目时,报错The requested module 'vue' does not provide an export named 'computed';

node版本问题,

Vite 需要 Node.js 版本 14.18+,16+;

升级node版本步骤:

先查看node的版本:

bash 复制代码
node -v;

安装n:

bash 复制代码
npm install -g n

sudo n latest // 升级到最新版本

sudo n stable // 升级到稳定版本

sudo n xx.xx // 升级到具体版本号

我采用的是升级到14.18.2

bash 复制代码
 sudo n 14.18.2

n 切换之后的 node 默认装在 /usr/local/bin/node,先用 which node 检查一下当前使用的 node 是否在这个路径下。是的话,就更新下/etc/profile文件指定:

bash 复制代码
source /etc/profile

node就完美升级到想要的版本,vite抛错也完美解决!

相关推荐
坠金2 分钟前
mac电脑网络卡顿解决方法
macos
写点啥呢1 小时前
MacOS远程桌面报错0x207解决方法
macos
CrankZ2 小时前
幕译 1.7--本地字幕生成与翻译--支持macOS,Windows
macos·whisper
ashcn20013 小时前
autohotkey模拟mac中英文切换和ESC切成英文(适配vim)
macos·autohotkey
大猫熊猫3 小时前
【ios】xcode运行项目时报错 Showing All Errors Only Framework ‘Pods_Runner‘ not found
macos·ios·xcode
weixin_4624462311 小时前
【原创实践】mac手动安装 wget
macos·wget
FreeBuf_14 小时前
认证噩梦:新型MacSync窃密木马绕过Gatekeeper劫持Mac设备
macos
绝世唐门三哥20 小时前
Mac 免费 GIF 录制软件全攻略:下载、安装与使用指南
macos·gif
雪域迷影1 天前
macOS系统上或首次使用Python的urllib模块时出现 ssl.SSLCertVerificationError 错误
python·macos·ssl
xincan08181 天前
MacOS安装Java+mvn+mvnd+jenv多环境丝滑切换
java·开发语言·macos