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');

3
25 comments

Hello!

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


Best regards,
Lena

3
Avatar
Permanently deleted user

Lena,

Thank you.

Tony

0
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

Yes.

In addition, I configured it.

m

0
Avatar
Permanently deleted user

Screen Shot 2015-05-05 at 12.31.15 AM.png

3

Please show the screenshot of your JavaScript libraries as well

0
Avatar
Permanently deleted user

Where is that?

m

0

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

0
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

I show it above.

m

0

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
Avatar
Permanently deleted user

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. 

 

7
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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

5

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

0
Avatar
Permanently deleted user

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

2

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

Webstorm: v2018.3.2

IntelliJ IDEA: v2018.3.5.

1

@S. M. Mir-Ismaili, please submit a support ticket, we'll take a look: https://intellij-support.jetbrains.com/hc/en-us/requests/new?ticket_form_id=66731

-1

Finally, I found a reason! Adding `@types/node` to dependencies (or `devDependencies`) can solve the issue.

See the attached video (22 sec) here.

1

@S. M. Mir-Ismaili Where did you add @types/node?

 

0

Please sign in to leave a comment.