Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm code completion for node.js, express and EJS

I'm learning node.js just now and am using WebStorm 7.0.2 to edit the code (I use this IDE on a daily basis for my other hmlt5 + JS work, but apparently don't know it as much as I'd thought :-)).

What I don't know yet is how to include additional modules in my project so that WebStorm sees them and provide code completion - I've got an issue with EJS - in the template files there're no suggestions and all the keywords are seen by WebStorm as unresolved. I've got similar issue with Express framework as a whole - functions like get/post/bodyParser are not recognized.

Somehow I managed to introduce a directory "node_modules/express" into my project but I have no idea how I did it - I've followed some example from google possibly..?

Can anyone kindly enlighten me what has to be done for WebStorm to see what's needed? I have Node.js Core Modules checked in my JavaScript->Libraries panel...

Thank you in advance for pointing me in a good direction. Piotr

like image 435
Piotr Górny Avatar asked Dec 19 '22 21:12

Piotr Górny


1 Answers

WebStorm suggests you to mark modules from your project's node_modules directory as external libraries automatically on the project start. You can also add modules manually in JavaScript | Libraries -> Add to get code completion for them.

There are some issues with code completion for Express framework. I suggest to download TypeScript definition files (Preferences: JavaScript | Libraries -> Download | TypeScript Community Stubs -> Express) to get proper completion for it.

Try having .ejs file type when you work with EJS templates.

like image 74
Ekaterina Prigara Avatar answered Dec 26 '22 01:12

Ekaterina Prigara