首页 > 解决方案 > 可以在 Vue 3 项目中安装 sass-loader

问题描述

我正在尝试在使用 vue CLI 创建项目之后添加 sass/scss 加载器。我运行了这个脚本: $ npm install -D sass-loader@^10 sass 我收到以下错误:

npm ERR! notsup Unsupported platform for fsevents@2.3.1: 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

它在我为测试它而创建的空项目中对我有用。但在我的项目中不起作用。我使用的是 Ubuntu 20.04,这是我的 package.json 文件:

{
  "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"
  ]
}

标签: node.jsvue.jsnpmsassvue-cli

解决方案


尝试删除您的package-lock.json文件和node_modules文件夹,然后再次安装您的依赖项

rm -r node_modules package.json
npm i

推荐阅读