【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抛错也完美解决!

相关推荐
denggun1234515 小时前
卡顿监测原理
macos·ios·xcode
Sheffi6618 小时前
iOS 触摸事件完整传递链路:Hit-Test 全流程深度解析
macos·ios·cocoa
ChineHe20 小时前
Gin框架入门篇002_第一个Gin服务
macos·xcode·gin
Roc.Chang20 小时前
解决 macOS 26.1 The application “xxxx” can’t be opened. 问题
macos
赶路人儿21 小时前
从intel mac迁移到M3后软件的兼容性
macos
颜淡慕潇21 小时前
Podman 从0到1使用教程(macOS 系统):安装 MySQL、Redis 容器
mysql·macos·podman
Niap.pr21 小时前
Macos下访问树莓派系统(ext4)
macos
芳草萋萋鹦鹉洲哦21 小时前
【mac】解决Apple无法验证“fsevents.node”是否包含可能危害Mac安全或泄漏隐私的恶意软件
安全·macos
aini_lovee1 天前
寻找 MAC 协议的 MATLAB 仿真
开发语言·macos·matlab
2501_915106322 天前
最新版本iOS系统设备管理功能全面指南
android·macos·ios·小程序·uni-app·cocoa·iphone