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

skatsumata picture skatsumata · Nov 22, 2013 · Viewed 134.6k times · Source

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

WebStorm shows a warning: "Unresolved function or method" for 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).

Environment:

  • WebStorm 7.0.2
  • Windows 7 64bit
  • Firefox Add-on SDK 1.15beta1

Answer

lena picture lena · Nov 22, 2013

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