Vuetify/Vue-CLI 编译问题;收到换行错误
Posted
技术标签:
【中文标题】Vuetify/Vue-CLI 编译问题;收到换行错误【英文标题】:Vuetify/Vue-CLI issues compiling; receiving newline error 【发布时间】:2020-02-10 11:55:10 【问题描述】:过去几个小时我一直在互联网上寻找答案。我快要疯了。
我有一个新的 Vue 项目,我从 vue-cli
开始,并添加了 Vuetify。当我运行 yarn serve
时,我收到了一百个错误抱怨:
ERROR Failed to compile with 100 errors 2:02:26 PM
error in ./node_modules/vuetify/src/components/VColorPicker/VColorPickerSwatches.sass
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
^
Expected newline.
╷
6 │ var content = require("!!../../../../css-loader/dist/cjs.js!../../../../sass-loader/lib/loader.js??ref--14-2!./VColorPickerSwatches.sass");
│ ^
╵
stdin 6:139 root stylesheet
in /Users/jimmiejackson/Documents/repositories/gear_closet/frontend/node_modules/vuetify/src/components/VColorPicker/VColorPickerSwatches.sass (line 6, column 139)
@ ./node_modules/vuetify/src/components/VColorPicker/VColorPickerSwatches.sass 4:14-343 14:3-18:5 15:22-351
@ ./node_modules/vuetify/lib/components/VColorPicker/VColorPickerSwatches.js
@ ./node_modules/vuetify/lib/components/VColorPicker/VColorPicker.js
@ ./node_modules/vuetify/lib/components/VColorPicker/index.js
@ ./node_modules/vuetify/lib/components/index.js
@ ./node_modules/vuetify/lib/index.js
@ ./src/plugins/vuetify.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.1.84:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
我尝试升级/降级sass-loader
,删除node-sass
,以及各种Webpack 配置(通过vue.config.js
)。有人有解决办法吗?
main.js
import Vue from 'vue';
import vueHeadful from 'vue-headful';
import vuetify from './plugins/vuetify';
import App from './App.vue';
import router from './router';
import store from './store/index';
Vue.config.productionTip = false;
Vue.component('vue-headful', vueHeadful);
new Vue(
router,
store,
vuetify,
render: h => h(App),
).$mount('#app');
vuetify.js
import Vue from 'vue';
import Vuetify from 'vuetify/lib';
import Unicon from 'vue-unicons';
import uniCarWash from 'vue-unicons/src/icons';
Vue.use(Vuetify);
Unicon.add([uniCarWash]);
Vue.use(Unicon);
export default new Vuetify(
icons:
iconfont: 'uni',
,
);
vue.config.js
const path = require('path');
module.exports =
transpileDependencies: [
'vuetify',
],
css:
loaderOptions:
sass:
data: `@import "~/scss/variables.scss"`,
,
,
,
chainWebpack: config =>
["vue-modules", "vue", "normal-modules", "normal"].forEach(match =>
config.module.rule('scss').oneOf(match).use('sass-loader')
.tap(opt => Object.assign(opt, data: `@import '~@/scss/variables.scss';` ));
);
,
configureWebpack:
resolve:
alias:
'~': path.resolve(__dirname, './src/'),
,
extensions: ['*', '.js', '.vue', '.json'],
,
module:
rules: [
test: /\.s(c|a)ss$/,
use: [
'vue-style-loader',
'css-loader',
loader: 'sass-loader',
options:
implementation: require('sass'),
fiber: require('fibers'),
,
,
],
,
],
,
,
;
package.json
"name": "newapp",
"version": "0.1.0",
"private": true,
"scripts":
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
,
"dependencies":
"axios": "^0.19.0",
"core-js": "^2.6.5",
"css-loader": "^3.2.0",
"style-loader": "^1.0.0",
"vee-validate": "^3.0.11",
"vue": "^2.6.10",
"vue-headful": "^2.0.1",
"vue-loader": "^15.7.1",
"vue-router": "^3.0.3",
"vuetify": "^2.1.0",
"vuex": "^3.0.1"
,
"devDependencies":
"@vue/cli-plugin-babel": "^3.12.0",
"@vue/cli-plugin-eslint": "^3.12.0",
"@vue/cli-service": "^3.12.0",
"@vue/eslint-config-airbnb": "^4.0.0",
"babel-eslint": "^10.0.1",
"deepmerge": "^4.1.1",
"eslint": "^5.16.0",
"eslint-import-resolver-webpack": "^0.11.1",
"eslint-plugin-vue": "^5.0.0",
"fibers": "^4.0.1",
"path": "^0.12.7",
"sass": "^1.17.4",
"sass-loader": "7.1.0",
"vue-cli-plugin-vuetify": "^1.0.1",
"vue-template-compiler": "^2.6.10",
"vuetify-loader": "^1.2.2"
【问题讨论】:
【参考方案1】:Vue CLI 有自己的 sass-loader
配置(并且已经在执行您配置的操作),因此您为 sass-loader
添加的规则是添加一个重复的处理器,其中 Vue CLI 的 @ 的输出987654324@ 被输入你的,导致错误。解决方案是删除 module.rules
的配置。
请注意,您还复制了 resolve.extensions
中的 Vue CLI 配置。我建议使用vue inspect
来查看项目已解析的 Webpack 配置以进行故障排除。在进行更改之前和之后区分输出会很有帮助。
【讨论】:
以上是关于Vuetify/Vue-CLI 编译问题;收到换行错误的主要内容,如果未能解决你的问题,请参考以下文章
c语言中 在编辑窗口,如果printf函数内字符过长,想要在编辑窗口换行,而且编译时不出问题,怎么办?