"build": "tsc src/index.ts"
I'm calling the script from the root dir of the project. Interestingly, running the same script with an --outDir flag works just fine.
When you pass in files for compilation with tsc src/index.ts, your tsconfig.json is ignored.
From the documentation:
When input files are specified on the command line, tsconfig.json
files are ignored.
Your npm build script should just be tsc without passing any files.
In my case it was being ignored because I had noEmit: true in tsconfig.json. For whatever reason, the files still were emitted, but in the same directory instead of following outDir.
The config file was read correctly and this error also appeared when using the flag.
–
If you are using the incremental compiler option, you may not be getting output if you have deleted / modified files in your outDir but have not removed the .tsbuildinfo file.
My issue was a bit different, but Google brought me here - so figured others may also.
–
–
Keep the typescript files in src folder and keep the tsconfig.json in root.
In tsconfig json file add foldername for outDir in compilerOptions
"compilerOptions": {
"outDir": "build",
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": true,
"sourceMap": true
and run the below commands.
just cd to the root folder and type
tsc --outDir .
Make sure "outDir" is defined under "compilerOptions"
I had it defined at the same level as "compilerOptions"
"compilerOptions": {
"baseUrl": "node_modules/@types",
"lib": [
"es6"
"outDir": "dist",
"esModuleInterop": true,
"exclude": [
"node_modules"
"include": [
"src/**/*"
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.