# scss 的坑

問題2更好的解決方案是這個

Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 8.x
Found bindings for the following Environments: Linux 64-bit with Node.js 12.x

以下是sass-loader的官方文檔

By default the loader resolve the implementation based on your dependencies. Just add required implementation to package.json (sass or node-sass package) and install dependencies.

Example where the sass-loader loader uses the sass (dart-sass) implementation:
package.json

{
  "devDependencies": {
    "sass-loader": "^7.2.0",
    "sass": "^1.22.10"
  }
}

Example where the sass-loader loader uses the node-sass implementation:

package.json

{
  "devDependencies": {
    "sass-loader": "^7.2.0",
    "node-sass": "^5.0.0"
  }
}

也就是說,可以直接使用sass而不用node-sass。
所以直接刪除掉node-sass,然后安裝sass吧
npm install sass sass-loader -D



  1. 項目中引入SCSS

    $ npm i sass-loader@10.x node-sass -D

    因為Vue環(huán)境用的是Vue@2.x ,如果直接安裝sass-loader會安裝11.x,該版本與Vue2.x不適配,可以裝10.x

    node-sass自動安裝,我本地是5.0.0

    -S 是 --save :安裝在packages.json的dependencies下面 -D 是 --save-dev :安裝在packages.json的devDependencies下面

  2. 安裝好node-sass和sass-loader以后,重新跑項目,報以下錯誤

    Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 8.x

    Found bindings for the following Environments: Linux 64-bit with Node.js 12.x

    node -v查看本地的node 版本就是12.x,但是sass-loader需要的是8.x

    如果本地有node.js的8.x版本,直接切換當前的node.js版本就行,使用N或者nvm

    如果本地沒有

    1. 官網(wǎng)找到對應的版本,下載安裝。
    1. $ npm rebuild sass-loader
    1. 重新運行項目
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 版權聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉載。 webpack介紹和使用 一、webpack介紹 1、由來 ...
    it筱竹閱讀 11,486評論 0 21
  • webpack介紹和使用 一、webpack介紹 1、由來 由于前端之前js、css、圖片文件需要單獨進行壓縮和打...
    yichen_china閱讀 669評論 0 0
  • Vue -漸進式JavaScript框架 介紹 vue 中文網(wǎng) vue github Vue.js 是一套構建用戶...
    桂_3d6b閱讀 948評論 0 0
  • 在網(wǎng)頁中會引用哪些常見的靜態(tài)資源? JS .js .jsx .coffee .ts(TypeScript ...
    瓔珞紈瀾閱讀 405評論 0 0
  • 什么是Vue.js Vue.js是目前最火的一個前端框架,React是最流行的一個前端框架,(React除了開發(fā)網(wǎng)...
    EEEEsun閱讀 739評論 0 1

友情鏈接更多精彩內(nèi)容