Crawling, installation and use of Sass in Vue (sass or node-sass)

Current use environment: 

node:v12.10.0

vue:  ^2.6.10

vue-cli: ^3.12.0

First of all, you must think that vscode does not report style errors, as shown below

Add some "material" to your style, tell vscode that you write sass

<style lang='scss' scoped>

 Then it reported an error

Alright, vscode knows that you write sass but there is no "thing" that can handle it

Next we will install sass-loader

cnpm install sass-loader -D

OK we try npm run serve 

An error was reported again, which is different from the error mentioned in various blogs Error: Cannot find module'node-sass';

So i modified sass

cnpm install sass -D

Npm run serve again

Turning point:

After installing sass-loader, instead of installing sass, install node-sass in the traditional way

cnpm install node-sass -D

No problem

So there must be some correlation between sass and node-sass.

summary:


cnpm install node-sass sass-loader --save-dev

//or

cnpm install sass sass-loader  --save-dev

Later I looked at several projects of the company and found that both were used

So there is no need to entangle whether to install sass or node-sass.

Guess you like

Origin blog.csdn.net/a1059526327/article/details/107843323