Vue.config.js
when i install sass and sass-loader how can i to configure to use sass Now i use sass tips error Cannot find module 'sass' from 'D:\demo\vite'
Vite improves @import resolving for Sass and Less so that Vite aliases are also respected. In addition, relative url() references inside imported Sass/Less files that are in different directories from the root file are also automatically rebased to ensure correctness.
Install vue 3 (You can probably skip this step if you have Vue already set up!) If you have the Vue CLI tool, just run vue create scss and select Vue 3. There is an option to set up CSS pre processors from the CLI tool but for this article I will ignore that option. Once set up, cd scss to move into that directory.
Using Vite to create the TypeScript React application. Before you start, you should have recent versions of Node and npm installed on your system. The first step is to use the Vite command to create a new application. This can be done using the npm init command without installing any additional software.
You just need to install sass using the following command
npm install -D sass
Also, you may check the official docs here https://vitejs.dev/guide/features.html#css-modules
Try
yarn add -D sass
it's pretty much the error given in the last screen.
Since people prefer to use NPM apparently but that there is a lot of package managers nowadays, here we do have an universal solution
By using ni, you can have
ni -D sass
to install that in your project whatever it's using NPM, yarn, PNPM or bun.
In other answers, they're using yarn
or npm
but If you're using pnpm
:
pnpm i -D sass
i
is an alias for install
:
https://pnpm.io/cli/install
-d
flag:
https://pnpm.io/cli/install#--dev--d
btw if you aready did npm i sass
you can perfectly do npm i -D sass
the changes will be made automagically!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With