I am trying to use Webstorm 10's new built-in TypeScript compiler. When compiling a simple Node.js file such as below, it gives a TS compilation error of "Error:(1, 15) TS2304: Cannot find name 'require'.
var express = require('express');
var router = express.Router();
var nconf = require('nconf');
I followed the "Downloading and installing a JavaScript-related library from WebStorm" section from https://www.jetbrains.com/webstorm/help/configuring-javascript-libraries.html. Using that dialog, I downloaded the node and express type definitions and can see them in the External Libraries section of my project. However, I still get the same error about "require".
How exactly should I be setting up Webstorm's TypeScript built-in compiler to work with the definition files downloaded from the External Libraries. Do I need to manually reference them in each .ts file and if so, what is the path of the files in "External Libraries". Also, shouldn't WebStorm automatically know about the definitions like Visual Studio does so I don't have to manually reference them? Is there some tsc compiler flag I can set in the built-in compiler's options to be aware of the definitions?
That dialog gets TypeScript definitions to use with JavaScript. You need to download the typescript definitions manually (using something like
tsd
is recommended) and then add them to your project.