Unresolved function or method require() at line 1

I'm using Webstorm 6 with Node and have setup the Node core modules.

When I run inspections I get the error:

Unresolved function or method require() at line 1

on the line:

var express = require('express');

21 comments

Hello!

in Settings/Project Settings/JavaScript/Libraries, check if you have 'Node.js Globals' enabled


Best regards,
Lena

3

I'm having the same problem in phpstorm 8.0.2

However there is no Node.js globals settings.  Is there something I can do?

2

Do you have NodeJS plugin installed and enabled?


0

Yes.

In addition, I configured it.

m

0

Please show the screenshot of your JavaScript libraries as well

0

Settings (Preferences on Mac) | Languages & Frameworks | JavaScript | Libraries

0

Screen Shot 2015-05-05 at 12.44.17 AM.png
I found it.

I don't think it was there before.  I checked off Node.js Globals, and now require  is working.

Some of the function called in my libraries and still showing is undefined.  Where and how do I add those?

m

1

Do those "some functions" have a name? Can you post a screenshot with the error/warning message?

In any case: I'm not JS/Node guy and will not be here on this one -- somebody else (from JB team) will be able to help you later. In meantime -- you may search this forum and Issue Tracker for this new issue.

0

For those who have this problem in their latest WebStorm/PhpStorm IDE versions (as at Feb 2017), you can go to File/Settings/Languages & Frameworks/Node.js and NPM/ and then under Coding Assistance subsection, find the enable option. 

 

4

@Thilina: Doesn't work. Shows bar then says Disable again.

0

For anyone else who comes along with 2018.3 (or later?), I ran into this same problem seemingly out of nowhere. Even though the project was configured correctly, code completion and analysis stopped working one day.  (The only major recent  change I can think of was disabling several plugins at once, but I didn't disable the Node plugin)

To fix it I had to:

* go into Settings -> Languages & Frameworks ->JavaScript -> Node.js and NPM

* disable "Coding assistance for Node.Js"

* Apply and CLOSE the settings dialog (I tried it once by just disabling, applying, and enabling, but nothing happened)

* Go back to the settings and re-enable it

After that the code completion worked

No idea what went wrong, but if anyone has some insights, I'd be grateful to hear

3

I had the same problem after updating to 2018.3, and I confirm that Brian Mcclure's method above fixed the problem.

0

Same problem, Brians method not working for me.  Version: 2018.3.4

1

Same issue. Unfortunately, Brian's method didn't work for me.

Webstorm: v2018.3.2

IntelliJ IDEA: v2018.3.5.

0

Please sign in to leave a comment.