Alon Alon - 1 year ago 171
TypeScript Question

Node.js reference path absolute

I have a Node.js project developed in WebStorm IDE

My project structure is:

A root folder named "root" that contains 2 folders: "main" and "typings". "main" contains one file named "foo.ts", "typings" contains one file named "bar.d.ts".

In foo.ts I added a reference path to bar.d.ts.

This works:

///<reference path="../typings/bar.d.ts" />

This does not work (getting "File not found"):

///<reference path="/typings/bar.d.ts" />

This does not work either:

///<reference path="/root/typings/bar.d.ts" />

How can I get rid of the 2 dots (..)?

Answer Source

How can I get rid of the 2 dots (..)

You can if you provide absolute path on disk. This is however not what you want.

If you want relative to project root, that isn't supported for reference tags.


Just use tsconfig.json and make sure it includes both foo and bar using e.g. files

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download