error TS6059: File is not under ‘rootDir’ .. ‘rootDir’ is expected to contain all source files

What is rootDir? rootDir is set to a root folder, that contains all your source files. If not specified, TS will automatically choose a suitable parent folder of all inputs. rootDir also determines the output directory. What does the error mean? My guess is you have an import statement for logging.ts somewhere in notifier-server: import … Read more

How to get tsc to Resolve Absolute Paths when Importing Modules using baseUrl?

The answer comes from @DenisPshenov’s comment in one of the answers. It’s buried, so I’ll provide it here… Tell Node where the base url is with NODE_PATH environment variable so that it can resolve absolute paths: Linux / macOS NODE_PATH=dist/ node ./dist/index.js Windows Powershell $env:NODE_PATH=”dist/” node ./dist/index.js

Maintain src/ folder structure when building to dist/ folder with TypeScript 3

I had a similar problem when initially converting to a TypeScript project. I also set resolveJsonModule: true and the src directory was copied to the output dist directory. The underlying reason is that one of my source files required package.json at the root of the project. Once I removed that, tsc no longer added src … Read more

Is there a way to use npm scripts to run tsc -watch && nodemon –watch?

I think what you want is something like this (my current setup): “scripts”: { “compile”: “tsc && node app.js”, “dev”: “./node_modules/nodemon/bin/nodemon.js -e ts –exec \”npm run compile\”” } I created two scripts “compile” and “dev”. To start developing you simply run npm run dev which starts nodemon and makes it watch .ts files (using the … Read more