How can I fix WebStorm warning “Unresolved function or method” for “require” (Firefox Add-on SDK)

后端 未结 13 1276
傲寒
傲寒 2020-12-04 10:38

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

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

I want to g

相关标签:
13条回答
  • 2020-12-04 11:02

    On WebStorm 2016.3

    1. Press ALT+F12 (open terminal)

    2. Run this command:

      npm install require.js
      
    0 讨论(0)
  • 2020-12-04 11:05

    Disable JetBrains Inspections and get the ESLint plugin.

    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.

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

    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"

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

    0 讨论(0)
  • 2020-12-04 11:07

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

    File -> Invalidate Caches/Restart...

    0 讨论(0)
  • 2020-12-04 11:07

    File->Settings->Languages & Frameworks->JavaScript

    0 讨论(0)
  • 2020-12-04 11:09

    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 and Frameworks/JavaScript/Libraries.

    (Edited settings path by @yurik)

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

    In IntelliJ 2018.3.2, go to Settings (Preferences) | Languages & Frameworks | Node.js and NPM and enable Coding assistance for Node.js

    0 讨论(0)
  • 2020-12-04 11:11

    In WebStorm 2018.3 a bit different interface

    0 讨论(0)
提交回复
热议问题