1.Unexpected 'debugger' statement. eslint no debugger
1.1package.json中找到eslintConfig配置项
1.2继续找到rules
1.3添加“no-debugger”: "off"
这里不成功就重新run dev,我在这边就需要重启服务,亲测有效
"rules": {
"no-debugger":"off"
}
2.Component name “XXX“ should always be multi-word
2.1.vue.config.js找到defineConfig配置项
2.2.添加lintOnSave: false
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false
})
当然了,也可以修改名字,不过配置项改一下一劳永逸
添加一下vue3+vite的配置过程
2.1.找到eslintrc.cjs文件
2.2.添加配置项rules,这个rules是对象
2.3.添加'vue/multi-word-component-names': 'off'
rules: {
'vue/multi-word-component-names': 'off'
}
3.The "xxx" component has been registered but not used.
vue3+vite的配置过程
2.1.找到eslintrc.cjs文件
2.2.添加配置项rules,这个rules是对象
2.3.添加'vue/no-unused-components': 'off'
rules: {
'vue/no-unused-components': 'off'
}
4.UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token '??='
这个问题我是在vue3+vite的项目中运行npm run dev碰到的
问题是node的版本不够(当时安装的node版本是14.16.1)
4.1.nvm install node 安装并使用最新的node
4.2.npm install 重新安装一下依赖
nvm的相关命令--mac端管理node
nvm current 当前node版本
nvm ls 所有安装的node版本
nvm alias default 切换默认使用的node版本
5.碰到正常情况下断点无法进入(或者断点后看见的不是源码),可尝试配置如下
找到vue.config.js,在defineConfig配置下添加,configureWebpack可以是Object || Function
configureWebpack: {
// 加入如下配置
devtool: "source-map",
},
6.unknown mutation type: xxx
这个地方如果使用了命名空间namespaced,记得需要在commit之后先去引用modules名字,如store.commit('user/setToken'),并确保在createStore的modules引入了对应的模块,这边我碰到了一个问题卡了半小时,namespaced一定要拼写正确,不然一下真找不到原因
7.vue命令报错SyntaxError: Unexpected token 如vue -help vue create xxx
提示是vue的语法报错,但vue源码肯定没有问题的。我这边的问题是node版本的问题导致的,这边通过切换从21.7.0切换成16.13.0的node版本就可以了,关于nvm和node的命令,可以看第4点,都是因为node版本的问题。在这里记录一下,也给大家少走一点弯路,多做正事!