'Can install sass-loader in Vue 3 project

I am trying to add sass/scss loader AFTER creating a project with vue CLI. I ran this script: $ npm install -D sass-loader@^10 sass and I am receiving following error:

npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

It worked for me in empty project that i created to test this. But in my project does not work. I am using Ubuntu 20.04 this is my package.json file:

{
  "name": "hikegear",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.34",
    "@fortawesome/free-solid-svg-icons": "^5.15.2",
    "@fortawesome/vue-fontawesome": "^3.0.0-3",
    "chart.js": "^2.9.4",
    "core-js": "^3.6.5",
    "sortablejs": "^1.13.0",
    "vue": "^3.0.5",
    "vue-router": "^4.0.3",
    "vuedraggable": "^4.0.1",
    "vuex": "^4.0.0-rc.2",
    "vuex-persistedstate": "^4.0.0-beta.3"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^7.0.0-0"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}


Solution 1:[1]

try deleting your package-lock.json file and node_modules folder and then installing your dependencies again

rm -r node_modules package.json
npm i

Solution 2:[2]

Yes you can. add following dependecis in your package.json and run npm i.

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

for add global variables you need to make vue.config.js in root directory if not exist. then add your scss varibale file.

module.exports = {
 
  css: {
    loaderOptions: {
      sass: {
        additionalData: '@import "@/assets/styles/file.scss";',
        implementation: require('node-sass')
      },
    },
  },

};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rassul
Solution 2