sass-loader安装+Failed to resolve loader: sass-loader You may need to install it.解决方法

时间:2024-01-27 08:04:38

方式一:

通过 cnpm 安装node-sass

 cnpm install node-sass --save 

方式二:

通过npm 安装

        1、安装sass-loader

 npm install sass-loader --save-dev 

        2、安装 node-sass

 npm install node-sass --save-dev

        如若不安装node-sass ,会出现如下错误:

ERROR  Failed to compile with 1 errors                                                                                                                                              3:13:52 PM
 error  in ./src/styles/index.scss
 Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
 Error: Cannot find module 'node-sass'
     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
     at Function.Module._load (internal/modules/cjs/loader.js:562:25)
     at Module.require (internal/modules/cjs/loader.js:692:17)
     at require (internal/modules/cjs/helpers.js:25:18)
     at getDefaultSassImplementation (D:\WebStormProject\tourism-supervision-service-platform\node_modules\sass-loader\dist\getDefaultSassImplementation.js:24:10)
     at getSassImplementation (D:\WebStormProject\tourism-supervision-service-platform\node_modules\sass-loader\dist\getSassImplementation.js:19:72)
     at Object.loader (D:\WebStormProject\tourism-supervision-service-platform\node_modules\sass-loader\dist\index.js:40:61)
 @ ./src/styles/index.scss 4:14-225 14:3-18:5 15:22-233
  @ ./src/main.js
  @ multi (webpack)-dev-server/client?http://localhost:9999/sockjs-node (webpack)/hot/dev-server.js ./src/main.js