[javascript] 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

This question is related to javascript firefox-addon webstorm firefox-addon-sdk

The answer is


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").


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

Instruction


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"
  ]

On WebStorm 2020.1

WebStorm -> Preferences -> Languages & Frameworks -> Node.js and NPM -> Check Coding assistance for Node.js -> Apply

WebStorm 2020.1 -> Preferences -> Languages & Frameworks -> Node.js and NPM -> Check Coding assistance for Node.js


For WebStorm 2019.3 File > Preferences or Settings > Languages & Frameworks > Node.js and NPM -> Enable Coding assitance for NodeJs

Note that the additional packages that you want to use are included.


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


Ok, Here I have seen a lot of answers already given, I want to add some more that are fixed unresolved function/method/variable warning.

That is resolved "unresolved function or method for 'require' and some other warning"

Go -> Preferences-> Languages & Frameworks -> Node.js and NPM, then checkmark the "Coding assistance for Node.js"

If you still see this type of warning, unresolved variable or something like that, you can manually disable these warnings by followings.

Go -> Preferences-> Editor-> Inspections-> JavaScript-> General.  

and you will find a list and just unchecked what warning you want to disable and then apply.


On WebStorm 2016.3

  1. Press ALT+F12 (open terminal)

  2. Run this command:

    npm install require.js
    

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


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.


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' enter image description here


In WebStorm 2018.3 a bit different interface enter image description here


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

File -> Invalidate Caches/Restart...


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to firefox-addon

Drag and drop menuitems Postman addon's like in firefox Convert URL to File or Blob for FileReader.readAsDataURL Getting "net::ERR_BLOCKED_BY_CLIENT" error on some AJAX calls How can I fix WebStorm warning "Unresolved function or method" for "require" (Firefox Add-on SDK) How to add java plugin for Firefox on Linux? Firefox Add-on RESTclient - How to input POST parameters? .setAttribute("disabled", false); changes editable attribute to false What is a MIME type? Parsing JSON from XmlHttpRequest.responseJSON

Examples related to webstorm

How to import js-modules into TypeScript file? How to ignore a particular directory or file for tslint? Difference between WebStorm and PHPStorm How can I fix WebStorm warning "Unresolved function or method" for "require" (Firefox Add-on SDK) What is the .idea folder? Can IntelliJ IDEA encapsulate all of the functionality of WebStorm and PHPStorm through plugins? What to gitignore from the .idea folder?

Examples related to firefox-addon-sdk

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