node-sass 常出現(xiàn)的兩個(gè)問題
一、node-sass 不支持 Mac M1
運(yùn)行安裝 node-sass 的項(xiàng)目報(bào)錯(cuò)如下
Syntax Error: Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Node.js 14.x
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.0
不支持 Mac M1 的 Arm 架構(gòu)
解決方式
// 1.刪除項(xiàng)目依賴包
rm -rf node_modules
// 2.重新安裝依賴 最好使用最新的淘寶源 registry=https://registry.npmmirror.com
npm install
// 3.安裝 sass
npm install sass
// 重新運(yùn)行項(xiàng)目即可正常運(yùn)行
二、node-sass 不支持當(dāng)前 node 版本
node-sass 對(duì) node 版本的支持比較慢,通常會(huì)落下多個(gè)正式的 node 版本,一般來說安裝當(dāng)前版本的前兩到三個(gè)正式版本即可
文章來源:http://www.zghlxwxcb.cn/news/detail-609010.html
解決方式
以 Mac M1 的 brew 安裝器的操作為例文章來源地址http://www.zghlxwxcb.cn/news/detail-609010.html
# 1.取消當(dāng)前node版本的鏈接
$ brew unlink node
# 2.查詢當(dāng)前有哪些可用node版本
$ brew search node
==> Formulae
libbitcoin-node node-build node@14 ? nodeenv
linode-cli node-sass node@16 nodenv
llnode node@10 node_exporter ode
node ? node@12 nodebrew
# 3.這里選擇安裝 node@14
$ brew install node@14
# 4.安裝成功后鏈接到 node@14 版本 會(huì)出現(xiàn)如下提示,安照提示刪除提示的文件即可
$ brew link node@14
Linking /opt/homebrew/Cellar/node@14/14.19.3...
Error: Could not symlink bin/npm
Target /opt/homebrew/bin/npm
already exists. You may want to remove it:
rm '/opt/homebrew/bin/npm'
To force the link and overwrite all conflicting files:
brew link --overwrite node@14
To list all files that would be deleted:
brew link --overwrite --dry-run node@14
# 5.因?yàn)樾碌膎ode版本會(huì)攜帶相關(guān)的包,和前一個(gè)node版本的起沖突,刪除一個(gè)然后提示下一個(gè),
# 具體路徑按照自己終端的提示刪除(刪除需謹(jǐn)慎)
$ rm /opt/homebrew/bin/npm
# 6.刪除后重新 link 出現(xiàn)如下提示則為切換 node 版本成功
$ brew link node@14
Linking /opt/homebrew/Cellar/node@14/14.19.3... 3900 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/opt/homebrew/opt/node@14/bin:$PATH"' >> ~/.zshrc
# 7.查看node版本,確認(rèn)是否替換成功
$ node -v
v14.19.3
$ npm -v
6.14.17
到了這里,關(guān)于Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!