运行 npm serve 时获取错误消息模块构建失败(来自 ./node_modules/sass-loader/dist/cjs.js) [英] Getting error message Module build failed (from ./node_modules/sass-loader/dist/cjs.js) when running npm serve

查看:82
本文介绍了运行 npm serve 时获取错误消息模块构建失败(来自 ./node_modules/sass-loader/dist/cjs.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从事 Vue/Vuetify 项目已经有一段时间了.直到昨天一切正常.我在使用 vuetify 组件时遇到了问题,所以我决定运行 npm install 并重新安装 vuetify:坏主意.

I'm working on a Vue/Vuetify project for quite some time now. It all worked fine until yesterday. I had problems with using the <v-simple-table> vuetify component, so I decided to run npm install and re-install vuetify: bad idea.

问题是我在运行 npm run serve 时多次收到以下错误:

The problem is that I get the following error multiple times when running npm run serve:

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
 - options has an unknown property 'indentedSyntax'. These properties are valid:
   object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }
    at validate (C:\Users\Jeroen\Documents\favourite_xi\node_modules\sass-loader\node_modules\schema-utils\dist\validate.js:49:11)
    at Object.loader (C:\Users\Jeroen\Documents\favourite_xi\node_modules\sass-loader\dist\index.js:36:28)

 @ ./node_modules/vuetify/src/components/VCalendar/mixins/calendar-with-events.sass 4:14-225 14:3-18:5 15:22-233
 @ ./node_modules/vuetify/lib/components/VCalendar/mixins/calendar-with-events.js
 @ ./node_modules/vuetify/lib/components/VCalendar/VCalendar.js
 @ ./node_modules/vuetify/lib/components/VCalendar/index.js
 @ ./node_modules/vuetify/lib/components/index.js
 @ ./node_modules/vuetify/lib/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://192.168.178.115:8080/sockjs-node ./node_modules/@vue/cli-service/node_modules/webpack/hot/dev-server.js ./src/main.js

我的 main.js 文件:

My main.js file:

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import Vuetify from 'vuetify/lib'
import 'vuetify/dist/vuetify.min.css'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

Vue.use(BootstrapVue)
Vue.use(Vuetify, {
  theme: {
    "primary": "#FFCA28",
    "secondary": "#1976D2",
    "accent": "#82B1FF",
    "error": "#FF5252",
    "info": "#2196F3",
    "success": "#4CAF50",
    "warning": "#FB8C00"
  }
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

我已经看过很多帖子了,他们都建议运行 npm rebuild node-sass(都在管理模式下定期运行),删除 node-modules 文件夹,重新安装 sass-loader,但到目前为止没有任何效果.

I've already looked at multiple posts and they all advise to run npm rebuild node-sass (both regularly as in admin-mode), delete the node-modules folder, re-install sass-loader, but nothing worked so far.

我的 main.js 可能有问题吗?

Is there something wrong in my main.js maybe?

提前致谢!如果我需要发布更多代码或其他信息,请告诉我.

Thanks in advance! Let me know if I need to post more of my code or additional information.

添加 package.json

added package.json

{
  "name": "favourite_xi",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "bootstrap": "^4.3.1",
    "bootstrap-vue": "^2.0.0-rc.22",
    "core-js": "^2.6.5",
    "node-sass": "^4.12.0",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "uuid": "^3.3.3",
    "vue": "^2.6.10",
    "vue-cool-select": "^2.10.2",
    "vue-flip": "^0.3.0",
    "vue-responsive-text": "^0.1.4",
    "vue-router": "^3.0.3",
    "vuetify": "^2.0.16",
    "vuex": "^3.1.1"
  },
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.10.1",
    "@vue/cli-plugin-babel": "^3.8.0",
    "@vue/cli-plugin-eslint": "^3.8.0",
    "@vue/cli-service": "^3.8.0",
    "@vue/eslint-config-standard": "^4.0.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.16.0",
    "eslint-plugin-vue": "^5.0.0",
    "sass-loader": "^8.0.0",
    "vue-template-compiler": "^2.6.10",
    "webpack": "^4.39.3"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "@vue/standard"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

推荐答案

这可能是将 sass-loader 从 v7.x 升级到 v8.x 的结果

This could be result of upgrading sass-loader from v7.x to v8.x

发行说明所述,它们v 对配置进行了重大更改

As stated in release notes, they'v made significant changes to configuration

检查你的 vue.config.js - 如果你发现这样的东西:

Check your vue.config.js - if you find something like this:

module.exports = {
  css: {
    loaderOptions: {
      sass: {
        ....some options here...
      }
    }
  }
}

改为:

module.exports = {
  css: {
    loaderOptions: {
      sass: {
        sassOptions: {
          ....some options here...
        }
      }
    }
  }
}

这篇关于运行 npm serve 时获取错误消息模块构建失败(来自 ./node_modules/sass-loader/dist/cjs.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆