I have a TypeScript project in IntelliJ and like to run a TypeScript scratch file to play with some code and libraries. I can run a scratch file without imports using a Node.js run configuration using --require ts-node/register as Node Parameters field (see help). However, if I try to import some project libraries, e.g.
import {of} from "rxjs/observable/of";
of('hi').subscribe(console.log);
I get TSError: ⨯ Unable to compile TypeScript because Cannot find module 'rxjs/observable/of'. I get no error if I use a regular TypeScript file in my project root (instead of a scratch file) or if I use require (instead of import), i.e.
const {Observable, of} = require("rxjs/observable/of");
of('hi').subscribe(console.log);
but I'd like to use a scratch file and the import syntax. What am I missing in my configuration?
Edit: I can not only compile the version with require without errors but also execute it without errors.
According to the help
To pass any additional parameters to ts-node (for example,
--project tsconfig.json), add them in the Application parameters field.
but if I use a non existing path instead of tsconfig.json, I get no complaints that the file does not exist. Is the option even taken into account by ts-node?