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

相关推荐
我的golang之路果然有问题16 小时前
mac配置 unity+vscode的坑
开发语言·笔记·vscode·macos·unity·游戏引擎
alanesnape21 小时前
Mac 目录树结构与基础 Linux 指令指南
macos
Digitally1 天前
解决“Move to iOS 卡在准备中”的 9 种有效方法
macos·ios·cocoa
影魅周影1 天前
解决mac端pycharm执行allure命令报错:returned non-zero exit status 127
ide·macos·pycharm
2501_927541092 天前
CameraBag Mac英文 照片视频滤镜编辑工具
macos
uiop_uiop_uiop2 天前
iOS arm64e hook MGCopyAnswer got Crash or Only Partial results got hooked
macos·ios·cocoa
私人珍藏库2 天前
[Mac] Unclutter 2.2.15 Mac上的文件暂存 智能剪贴板历史记录管理器工具
macos
哈茶真的c2 天前
【Mac】开发环境使用/维护
macos
醇氧2 天前
mac 安装 LibreOffice
macos
马拉萨的春天2 天前
iOS中如果一个大图500M直接加载显示会崩溃,那么如何设置加载显示呢?
macos·ios·cocoa