npm install -D sass-loader node-sass Vue.js 2021
Asked Answered
Z

5

20

Hi issue is setting up SASS for Vue.js I run: Node.js - 15.7.0 Vue.js - @vue/cli 4.5.11 This is an error in the console I am having while running this command: npm install -D sass-loader node-sass

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"2 || 3 || 4" from [email protected]
npm ERR!   node_modules/babel-loader
npm ERR!     dev babel-loader@"^7.1.1" from the root project
npm ERR!   peer webpack@"^3.1.0" from [email protected]
npm ERR!   node_modules/extract-text-webpack-plugin
npm ERR!     dev extract-text-webpack-plugin@"^3.0.0" from the root project
npm ERR!   8 more (file-loader, friendly-errors-webpack-plugin, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev sass-loader@"*" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^4.36.0 || ^5.0.0" from [email protected]
npm ERR!   node_modules/sass-loader
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See C:\Users\marko\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\marko\AppData\Local\npm-cache\_logs\2021-01-28T16_11_07_342Z-debug.log
Zorina answered 28/1, 2021 at 16:13 Comment(1)
Please mark the answer as acceptedInterregnum
H
56

I had the same problem today. Try installing sass-loader v10.0.5 instead:

npm install -D [email protected] node-sass
Herniorrhaphy answered 22/2, 2021 at 21:20 Comment(1)
This works! Though we need to install appropriate node-sass version as per the node version installed in the machine as per the answer https://mcmap.net/q/63815/-error-39-node-sass-39-version-5-0-0-is-incompatible-with-4-0-0Debora
S
14

Actually, there's a note about this issue in Vue CLI docs:

When using webpack version 4, the default in Vue CLI 4, you need to make sure your loaders are compatible with it. Otherwise you will get errors about confliciting peer dependencies. In this case you can use an older version of the loader that is still compatible with webpack 4.

npm install -D sass-loader@^10 sass

Spin answered 28/10, 2021 at 22:40 Comment(2)
This is the one that worked for me. Wish this had more points since the Vue CLI docs seem to already address itShavon
This also worked for me.Coquelicot
R
4

I also got this error when install sass-loader. Fix it by the reference here: https://github.com/laravel-mix/laravel-mix/issues/2562

Need to add --legacy-peer-deps to resolve it. enter image description here

enter image description here

Roofing answered 7/9, 2021 at 5:56 Comment(1)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Inductee
S
2

i fixed this bug by running npm install --force

Supporter answered 4/8, 2022 at 11:43 Comment(0)
D
1

Have you tried to use sass instead of node-sass?

Dashed answered 5/11, 2021 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.