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

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

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

Solutions/Answers:

Solution 1:

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

(Edited settings path by @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

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

Solution 2:

Webstorm 11 and 2016.2.3

Enable Node.js Core library in Webstorm settings.

enter image description here

enter image description here

enter image description here

Solution 3:

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

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

Then click the enable button (apparently in new versions, it is called “Coding assistance for Node”).

Related:  Multiple detached webview instances seen in chrome devices while navigating in hybrid android app

Solution 4:

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

File -> Invalidate Caches/Restart…

Solution 5:

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

Get node.d.ts from DefinitelyTyped on GitHub

Or just run:

npm install @types/node --save-dev

Then in tsconfig.json, include

"types": [
     "node"
  ]

Solution 6:

In WebStorm 2018.3 a bit different interface
enter image description here