vscode package.json字符串与模式不匹配 [英] vscode package.json String does not match the pattern

查看:644
本文介绍了vscode package.json字符串与模式不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用npm的现有项目中尝试VSCode,并具有一个package.json文件和相应的"name:"键,该键读取"SpecPro-File-Management-UI". VSCode反对使用字符串与模式不匹配..."这一行,这显然是因为名称中的字母大写.

I am trying out VSCode on an existing project that uses npm and has a package.json file with a corresponding "name:" key that reads "SpecPro-File-Management-UI". VSCode is objecting to this line with "String does not match the pattern ...", apparently because of the upper-case characters in the name.

已解决的 VSCode问题中描述了此问题.这给我留下了为我的程序包设置自定义架构的建议 .json文件.这是非常不友好的,并且是采用VSCode的障碍.我不想花时间在自定义架构上.我不想重命名我的项目.我只想编辑我的代码并利用许多VSCode优点,而不会分散错误消息.

This problem is described in a VSCode issue which is closed. Which leaves me with advice to setup a custom schema for my package.json file. This is pretty unfriendly, and a barrier to adopting VSCode. I don't want to spend my time on custom schemas. I don't want to rename my project. I just want to edit my code and take advantage of the many VSCode goodies without distracting messages that are wrong.

考虑到npm包中使用大写字符是非常常见的做法,似乎最合理的做法是VSCode应该采用更友好的模式或简便的方法来覆盖标准模式.据我所知,我必须制定自己的个人方案来解决此问题.这样一个简单的问题需要大量的工作和以后的维护.

Considering that using uppercase characters for npm packages is a VERY common practice, it seems most reasonable that VSCode should adopt either a more friendly schema or an easy way to override the standard schema. As far as I can tell, I have to make my own personal schema to resolve this problem. That's a lot of work and future maintenance for such a simple issue.

是否有一种简便的方法来消除此错误错误消息?

Is there an easy way to banish this erroneous error message?

推荐答案

此行为是设计使对package.json文件强制执行NPM约定的(换句话说,仅小写").我同意这很麻烦,尤其是因为通常会预先填写项目名称,例如通过"create-react-app".如您所指出的,可以创建一个自定义模式来忽略它,但是实际上不建议这样做.目前没有其他选择.我自己,我只是将值更改为小写.

This behavior is by design to enforce NPM conventions for the package.json file (to paraphrase, "lower-case only"). I agree it is a nuisance, especially since the project name is often pre-filled, e.g. by "create-react-app". As you point out, it is possible to create a custom schema to ignore this, but it's really not recommended. There isn't any alternative at this time. Myself, I just change the value to lower-case.

这篇关于vscode package.json字符串与模式不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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