使用 WebStorm 时未解析的变量架构 [英] Unresolved variable Schema when using WebStorm

查看:37
本文介绍了使用 WebStorm 时未解析的变量架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WebStorm 并且启用了具有 JavaScript 标准样式的节点模块 (

它在编译时不应该给我任何错误,但在尝试遵循标准时很烦人,因为我收到很多关于预期 6 个空格发现 8 个"之类的错误,我检查每个错误并看到这样的东西.有大佬知道怎么解决吗?

通过禁用节点模块编码辅助(设置 -> 语言和框架 -> Node.js 和 NPM)设法修复了未解析的变量架构",但现在诸如 required 之类的东西未解决.这是一张图片

有没有办法让我的 Node.js 提示和 WebStorm 理解 mongoose 和其他对象及其属性?

顺便说一句 - 你看到的这个 TODO - 是因为 WebStorm 给了我关于 ObjectID 大写 D 的提示,而在其他地方它是大写 D.这太疯狂了.

解决方案

目前不确定这是否与任何人相关,但要解决 WebStorm 中与猫鼬相关的未解析变量曲线,您需要转到

文件 > 设置...

语言和框架,您需要选择JavaScript(不是Node.js 和NPM)类别.

在该类别下选择图书馆.

如果您还没有下载任何其他要使用的库,您可能会看到类似于以下内容的列表:

在列表右侧选择下载...按钮.

将弹出一个包含库列表的窗口,向下滚动直到找到 mongoose,选择它并点击下载和安装按钮.

之后,您的库列表可能如下所示:

Webstorm 现在应该能够理解与猫鼬相关的类型和变量等,并且还应该为这些提供自动完成选项.

I am using WebStorm and I have enabled Node Modules in which I have JavaScript Standard Style ( https://standardjs.com ) and it works fine. It underlines when I have ';' or anything like this (basically not following the standard ). When I use mongoose ( const mongoose = require('mongoose') you most probably are familiar with it) and I decide to create model and make the following code

let userSchema = mongoose.Schema({
  username: {type: mongoose.Schema.Types.String, required: true},
  profilePicture: {type: mongoose.Schema.Types.String, required: false},
})

There are more fields but the code is repeating. WebStorm gives me hints about what is in mongoose, Schema and Types, but it underlines them and gives the following

Unresolved variable Schema

and after that

Unresolved variable Types

Here is how it looks

It should not give me any errors while compiling but it is quite annoying when trying to follow the standard because I get lots of errors about stuff like "expected 6 spaces found 8" and I check every error and see stuff like this. Does anyone know how to fix it?

EDIT: Managed to fix "Unresolved Variable Schema" by disabling Node Modules coding assistance ( Settings -> Language & Frameworks -> Node.js and NPM) ,but now things like required are Unresolved. Here is a picture

Is there a way to have my Node.js hints and also WebStorm understanding mongoose and other objects and their properties?

Btw - This TODO you are seeing - is because WebStorm gives me hints about ObjectID being with capital D, while in other places it is with lower D. This shit crazy.

解决方案

Not sure if this is relevant for anyone at this point but to solve these mongoose related unresolved variable squigglies in WebStorm you need to go to

File > Settings...

Under Languages & Frameworks, you'll need to select the JavaScript (not Node.js and NPM) category.

Under that category select Libraries.

If you have not downloaded any additional libraries to be used, you'll probably see a list similar to something like this:

On the right of the list select the Download... button.

A window with a list of libraries will pop up, scroll down until you find mongoose, select it and hit the Download and Install button.

After that, your list of libraries will probably look something like this:

Webstorm should now be able to understand mongoose related types and variables etc, and should also provide auto-complete options for those as well.

这篇关于使用 WebStorm 时未解析的变量架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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