如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

时间:2022-10-30 07:23:15

I'm using WebStorm 7 for Firefox Add-on SDK development.

我正在使用WebStorm 7为Firefox附加SDK开发。

WebStorm shows a warning: "Unresolved function or method" for require().

WebStorm显示了一个警告:require()的“未解析函数或方法”。

I want to get rid of the warning.

我想去掉这个警告。

var pageMod = require("sdk/page-mod");

NOTE:I already configured JavaScript-library (refer /lib/sdk globals).

注意:我已经配置了javascript库(参考/lib/sdk globals)。

Environment:

环境:

  • WebStorm 7.0.2
  • WebStorm 7.0.2
  • Windows 7 64bit
  • Windows 7 64位
  • Firefox Add-on SDK 1.15beta1
  • 火狐插件beta1 SDK 1.15

8 个解决方案

#1


268  

Do you mean that 'require()' is not resolved? You need to either add require.js to your project, or enable Node.js Globals predefined library in Settings/Languages & Frameworks/JavaScript/Libraries

您的意思是“require()”没有解决吗?您需要添加需求。项目或启用节点的js。在设置/语言&框架/JavaScript/库中预定义的库

(Edited settings path by @yurik)

(编辑设置路径@yurik)

In WebStorm 2016.x-2017.x: make sure that Node.js Core library is enabled in Settings (Preferences) | Languages & Frameworks | Node.js and NPM

在WebStorm 2016. x - 2017。x:确定那个节点。在设置(首选项)|语言和框架|节点中启用了js核心库。js和NPM

#2


193  

Webstorm 11 and 2016.2.3

Webstorm 11和2016.2.3

Enable Node.js Core library in Webstorm settings.

启用节点。在Webstorm设置中的js核心库。

如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

#3


27  

After spending an hour trying to get this to work using all solutions found online, this finally did the trick!

在花了一个小时尝试使用在网上找到的所有解决方案使其工作之后,这最终达到了目的!

File -> Invalidate Caches/Restart...

文件- >缓存失效/重启……

#4


19  

In PHPStorm, it's a bit easier: you can just search for NPM in settings or:

PHPStorm要简单一些:你可以在设置中搜索NPM,或者:

File > Settings > Language & Frameworks > Node.js and NPM

Then click the enable button.

然后单击enable按钮。

#5


10  

Working with Intellj 2016, Angular2, and Typescript... the only thing that worked for me was to get the Typescript Definitions for NodeJS

与intelligent j 2016、Angular2和Typescript合作…对我来说,唯一有用的是获得NodeJS的打字稿定义

Get node.d.ts from DefinitelyTyped on GitHub

得到node.d。肯定是从GitHub上输入的

Or just run:

或者只是运行:

npm install @types/node --save-dev

——save-dev npm安装@types /节点

Then in tsconfig.json, include

然后在tsconfig。json,包括

"types": [
     "node"
  ]

#6


3  

Solution on Webstorm 2016.3

解决方案在Webstorm 2016.3

1) click on ALT+F12 (open treminal)

1)点击ALT+F12(打开treminal)

2) run the command: npm install require.js

2)运行命令:npm安装require.js。

#7


3  

Disable JetBrains Inspections and get the ESLint plugin.

禁用JetBrains检查并获得ESLint插件。

The only thing that File | Invalidate caches and restart does for me is reset it long enough to trick me into thinking the error is gone. Once the inspections run again the error comes back like a gift that keeps on giving.

文件| Invalidate缓存和restart为我做的唯一一件事是重置它的时间足够长,使我误以为错误已经消失。一旦检查再次进行,错误就会回来,就像一份不断给予的礼物。

I saved myself all that frustration by disabling all JetBrains inspections (Editor > Inspections > uncheck JavaScript) Then I installed the ESLint plugin.

通过禁用所有JetBrains检查(编辑器>检查>不检查JavaScript),我避免了所有的挫败感,然后我安装了ESLint插件。

The inspection that causes "Unresolved function method" can be turned off by going to JetBrains inspections (Editor > Inspections > JavaScript) and searching for "Unresolved Javascript" and turning off "Unresolved Javascript function" and "Unresolved Javascript variable"

可以通过JetBrains检查(编辑器>检查> JavaScript)和搜索“未解决的JavaScript”以及关闭“未解决的JavaScript函数”和“未解决的JavaScript变量”来关闭导致“未解决的JavaScript方法”的检查

I killed them all and have edited my code hassle free ever since.

我把他们都杀了,从那以后我就不再为代码操心了。

#8


2  

Another solution that helped me a lot is to update all libs in "Node.js and NPM". You need just mark all libs and click blue arrow - 'update' 如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

另一个非常有用的解决方案是更新“Node”中的所有lib。js和NPM”。您只需标记所有的libs并单击蓝色箭头-“update”

#1


268  

Do you mean that 'require()' is not resolved? You need to either add require.js to your project, or enable Node.js Globals predefined library in Settings/Languages & Frameworks/JavaScript/Libraries

您的意思是“require()”没有解决吗?您需要添加需求。项目或启用节点的js。在设置/语言&框架/JavaScript/库中预定义的库

(Edited settings path by @yurik)

(编辑设置路径@yurik)

In WebStorm 2016.x-2017.x: make sure that Node.js Core library is enabled in Settings (Preferences) | Languages & Frameworks | Node.js and NPM

在WebStorm 2016. x - 2017。x:确定那个节点。在设置(首选项)|语言和框架|节点中启用了js核心库。js和NPM

#2


193  

Webstorm 11 and 2016.2.3

Webstorm 11和2016.2.3

Enable Node.js Core library in Webstorm settings.

启用节点。在Webstorm设置中的js核心库。

如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

#3


27  

After spending an hour trying to get this to work using all solutions found online, this finally did the trick!

在花了一个小时尝试使用在网上找到的所有解决方案使其工作之后,这最终达到了目的!

File -> Invalidate Caches/Restart...

文件- >缓存失效/重启……

#4


19  

In PHPStorm, it's a bit easier: you can just search for NPM in settings or:

PHPStorm要简单一些:你可以在设置中搜索NPM,或者:

File > Settings > Language & Frameworks > Node.js and NPM

Then click the enable button.

然后单击enable按钮。

#5


10  

Working with Intellj 2016, Angular2, and Typescript... the only thing that worked for me was to get the Typescript Definitions for NodeJS

与intelligent j 2016、Angular2和Typescript合作…对我来说,唯一有用的是获得NodeJS的打字稿定义

Get node.d.ts from DefinitelyTyped on GitHub

得到node.d。肯定是从GitHub上输入的

Or just run:

或者只是运行:

npm install @types/node --save-dev

——save-dev npm安装@types /节点

Then in tsconfig.json, include

然后在tsconfig。json,包括

"types": [
     "node"
  ]

#6


3  

Solution on Webstorm 2016.3

解决方案在Webstorm 2016.3

1) click on ALT+F12 (open treminal)

1)点击ALT+F12(打开treminal)

2) run the command: npm install require.js

2)运行命令:npm安装require.js。

#7


3  

Disable JetBrains Inspections and get the ESLint plugin.

禁用JetBrains检查并获得ESLint插件。

The only thing that File | Invalidate caches and restart does for me is reset it long enough to trick me into thinking the error is gone. Once the inspections run again the error comes back like a gift that keeps on giving.

文件| Invalidate缓存和restart为我做的唯一一件事是重置它的时间足够长,使我误以为错误已经消失。一旦检查再次进行,错误就会回来,就像一份不断给予的礼物。

I saved myself all that frustration by disabling all JetBrains inspections (Editor > Inspections > uncheck JavaScript) Then I installed the ESLint plugin.

通过禁用所有JetBrains检查(编辑器>检查>不检查JavaScript),我避免了所有的挫败感,然后我安装了ESLint插件。

The inspection that causes "Unresolved function method" can be turned off by going to JetBrains inspections (Editor > Inspections > JavaScript) and searching for "Unresolved Javascript" and turning off "Unresolved Javascript function" and "Unresolved Javascript variable"

可以通过JetBrains检查(编辑器>检查> JavaScript)和搜索“未解决的JavaScript”以及关闭“未解决的JavaScript函数”和“未解决的JavaScript变量”来关闭导致“未解决的JavaScript方法”的检查

I killed them all and have edited my code hassle free ever since.

我把他们都杀了,从那以后我就不再为代码操心了。

#8


2  

Another solution that helped me a lot is to update all libs in "Node.js and NPM". You need just mark all libs and click blue arrow - 'update' 如何修复“需要”的WebStorm警告“未解决的功能或方法”(Firefox附加SDK)

另一个非常有用的解决方案是更新“Node”中的所有lib。js和NPM”。您只需标记所有的libs并单击蓝色箭头-“update”