4

I am trying to create a simple TypeScript project in WebStorm that imports a Node.js module. I have downloaded the relevant library TypeScript definition in settings and have specified --module commonjs in compiler settings, but I am receiving a Cannot find external module error when I try to actually import the module.

This is the most basic example I can think of. What am I missing here?

Source Code + Project Layout Library Settings TypeScript Compiler Settings

1

2 Answers 2

2

I think you may need at the very top of your file:

/// <reference path="node.d.ts" />

I'm not yet sure how to reference the Definitely Type node definitions you've downloaded inside the Webstorm IDE.

Try manually download node.d.ts from:

https://github.com/borisyankov/DefinitelyTyped/blob/master/node/node.d.ts

and drop it into your working directory.

Sign up to request clarification or add additional context in comments.

3 Comments

Definition files downloaded via JavaScript - Libraries are External libraries used by WebStorm to enhance code completion (more on that (more on that here). If you want to use then for compilation, you need to download that from GitHub and add to your project files.
Sorry, let this one slip by. I did try manually adding the files, and it didn't seem to work unless it was in the same directory. It's quite possible I did it incorrectly at the time. That said, I think we determined there are two bugs in WebStorm: youtrack.jetbrains.com/issue/WEB-16512.
@mdierker According to your report, it is still not fixed. Absolute path and symlink would not help to solve this?
0

If you are using tsconfig.json then you can tell WebStorm to use it. Search for it under Languanges & Frameworks > TypeScript

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.