惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Hacker News: Ask HN
Hacker News: Ask HN
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
月光博客
月光博客
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
F
Full Disclosure
U
Unit 42
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
腾讯CDC
T
Threatpost
H
Hacker News: Front Page
P
Palo Alto Networks Blog
博客园 - 聂微东
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy

Aemon's Blog

给 Hexo 博客换上 Giscus 评论系统 用 Pandoc 把 Markdown 简历转成 HTML 和 PDF 榨干这台NAS第006话-关于备份 榨干这台 NAS 第 005 话-外网访问之 Tailscale 榨干这台 NAS 第 004 话-刮削 榨干这台 NAS 第 003 话-硬链接 榨干这台 NAS 第 002 话-下载工具 榨干这台 NAS 第 001 话-文件浏览器(File Browser) 榨干这台 NAS 第 000 话-目录结构 煎蛋保险小课堂 What is this thing 15 What is this thing 14 如何「黑入」你的特斯拉 What is this thing 13 emoji 背后的故事 What is this thing 12 A puzzle a day What is this thing 11 微波炉简易使用指南 What is this thing 10 青旅
nvm use 命令不生效问题以及解决方法
Aemon · 2021-06-17 · via Aemon's Blog

问题

今天启动项目的时候发现报错了,提示说 node-sass 的版本不适用当前版本的 nodenode-sass 官网有一张表格,记录着 node-sassnode 的对应版本:

NodeJS Supported node-sass version Node Module
Node 16 6.0+ 93
Node 15 5.0+ 88
Node 14 4.14+ 83
Node 13 4.13+, <5.0 79
Node 12 4.12+ 72
Node 11 4.10+, <5.0 67
Node 10 4.9+, <6.0 64
Node 8 4.5.3+, <5.0 57
Node <8 <5.0 <57

我使用的 node-sass 版本为:

1
"node-sass": "^4.12.0"

我记得我的 node 版本应该是 v14.16.0,应该不会有问题啊。

解决?

但是试了几次 npm run serve,都是报错,于是我只好查看了一下我的 node 版本:

1
2
> node --version
v16.3.0

v16.3.0???

我明明是 v14.16.0 啊,怎么变成 v16.3.0 了?我想起前几天好像是用 nvm 安装了一个当前最新的版本,可能那时候安装好没切换回来吧,于是我:

1
2
> nvm use v14.16.0
Now using node v14.16.0 (npm v7.15.1)

大问题

ok!easy,于是我愉快的 npm run serve,靠!怎么还是报错?

我再次查看了一下我的 node 版本:

1
2
> node --version
v16.3.0

怎么没切过去?出了什么问题?

上网查了好多资料,大多数都让我卸载 nvmnode 重新安装的。但是我不想把我的环境搞得一团糟,所以我一直在搜索有没有其他的的解决方案。

终于我看到一个方案是:看看有没有安装除了 nvm 安装的其他 node

于是:

1
which -a node

果然,除了 nvm 下的 node,还有 homebrew 也有个 node。之后我又确认了一下:

1
brew list

确实,列表中有 node。之后我看了我的 history,因为我记得我没有用 homebrew 安装过 node,翻了一遍,确实没有,虽然很好奇,但是我还是准备动手删了它!

1
brew uninstall node

但是却提示:

Error: Refusing to uninstall /opt/homebrew/Cellar/node/16.3.0
because it is required by yarn, which is currently installed.

yarn?原来是你!我终于想到昨天下午为了搭建一个新项目的环境,我安装了 yarn,由于它是依赖于 node 的,所以 homebrew 顺便帮我安装了 node。知道了原因,接下来就好办了。

解决

首先卸载 yarn

1
brew uninstall yarn

然后卸载 node

1
brew uninstall node

之后再重新安装 yarn 并加上忽略依赖项参数:

1
brew install yarn --ignore-dependencies

至此,nvmyarn 终于能和谐共处啦🎉!

参考