首页 > 技术文章 > vscode配置问题

shusonghe 2021-05-20 14:11 原文

1.vscode好用的插件

chinese(汉化)
material theme(主题)
prettier(美化代码,设置Format On Save勾选)

 

2.vscode格式化不换行

左下角管理点开,选择设置。在用户设置下找到vetur,打开settings.json
 

 

放入下面的配置保存:

"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_line_length": 120,
"wrap_attributes": "auto",
"end_with_newline": false
}
}

 

3.解决eslint报错的问题

1.安装eslint插件
2.在vscode的左上角点击文件-首选项-设置-扩展-eslint-settings.json编辑
3.在项目中.eslintrc.js里面的rules下添加'linebreak-style':'off'

 

4.解决npm下载过慢甚至卡住的问题

刚安装完node的时候,使用npm安装项目经常会卡住。原因是npm的下载地址是国外的。 解决方案是将npm的下载地址转回淘宝的地址。
这个方法不需要安装cnpm,只需要修改一下地址就可以了。

我们可以使用命令npm config get registry查看npm默认下载地址。
可以看到默认的地址是https://registry.npmjs.org/
使用命令npm config set registry https://registry.npm.taobao.org将默认下载地址改成淘宝镜像就可以了。
再使用命令npm config get registry查看是否修改成功。

 

5.npm run dev报错

检查veu、nodejs、webpack版本是否有冲突
vue -V
node -v
npm info webpack

全局卸载webpack
npm uninstall webpack -g

安装2.9版本的webpack
cnpm install webpack-dev-server@2.9.7

 

6.npm常用指令

打包
git add .
git commit -m "20220622_02"
git status
git push
git log  获得版本号
git merge origin/songhe  合并代码
git pull origin master  拉取其他分支

配置npm
npm config set registry http://maven.paic.com.cn/repository/npm/
yarn config set registry http://maven.paic.com.cn/repository/npm/
设置淘宝npm源
npm config set registry http://registry.npm.taobao.org
yarn config set registry http://registry.npm.taobao.org
查询npm版本
npm config get registry
yarn config get registry
npm切换版本
npm install npm@7.21.1 -g

安装秘钥
https://www.cnblogs.com/yjlch1016/p/9692840.html

 

推荐阅读