I'm using WebStorm as the IDE.
Here's my folder structure and express.js insalled:
But my sample code is not aware of the require keyword:
var express = require('express'); var app = express(); app.listen(1337, function(){ console.log("ready"); });
Update
Per Darin's answer Here's my package.json file which now sits in the root of the Website folder:
{ "name": "MyTestSite.com", "version": "0.0.1", "description": "A Website", "main": "test.js", "directories": { "test": "tests" }, "dependencies": { "express": "^4.11.2" }, "devDependencies": {}, "scripts": { "test": "n/a" }, "repository": { "type": "git", "url": "https://github.com/n/a" }, "keywords": [ "express" ], "author": "My Name", "license": "n/a", "bugs": { "url": "https://github.com/n/a/issues" }, "homepage": "https://github.com/n/a" }
This was created with npm init. I don't think I need all that crap in there so now I just have:
{ "name": "MyTestSite.com", "version": "0.0.1", "description": "A Website", "main": "test.js", "directories": { "test": "tests" }, "dependencies": { "express": "^4.11.2" } }
I must have something malformed here...WebStorm still doesn't recognize the require keyword.
require is a keyword for npm isn't it?
To run a script, open it in the editor or select it in the Project tool window, and then select Run <script file name> from the context menu. WebStorm creates a temporary run/debug configuration of the type Node. js. To run a test, click the gutter icon next to it or press Ctrl+Shift+F10 .
WebStorm lets you run and debug Node. js applications using Node. js on Windows Subsystem for Linux.
Yes. It's a great IDE to use with web design and coding for developers of all skills from beginner to expert. If you are interested in end-to-end (full stack) development using PHP then I recommend PhpStorm which has the same features of WebStorm but also innate support for PHP.
In Webstorm, there are three places in your settings (ctrl-alt-s
) where you can update settings for Node.js projects.
Settings: Javascript Libraries
First, in Javascript | Libraries
you can specify that Node libraries should be loaded. Your set of libraries may look different than this, but it should be pretty close...or, if needed, you can add the libraries so that your flavor (node, io, whatever) shows up.
JSHint
Second, if you have JSHint enabled, you should also enable the Node.js environment so that JSHint acts appropriately.
Nodejs and NPM Settings
You can (should) also set the path to your node executable. Webstorm will also detect your globally installed modules, too, and show you if your versions are up-to-date.
The Official Docs
Finally, this reference link contains much more information about WebStorm and Node: JetBrains Webstorm -- Nodejs Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With