简体   繁体   中英

tsc not creating the dist folder

All is in the title, trying to compile my TypeScript project to ./bin folder, the tsc commend execute without error resulting in nothing created, can't figure out why.

my tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "lib": ["es6", "es7", "dom", "esnext"],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmit": true,
    "noImplicitAny": false,
    "outDir": "bin",
    "removeComments": true,
    "sourceMap": true,
    "target": "es2017",
    "rootDirs": ["src/", "config/"],
    "typeRoots": ["./node_modules/@types", "./typings"]
  },
  "include": ["src/**/*", "./typings"],
  "exclude": ["node_modules", "bin", "**/__mocks__*", "**/*.spec.**", "test", "assets"]
}

In my package.json this is my scripts to compile:

"scripts": {
    "build-ts": "tsc",
    "watch-ts": "tsc -w",
  },

the structure of my project:

rootdir
    |
    |-----src
    |      |----server.ts
    |      |----app.ts
    |-----test
    |-----node_modules
    |-----typings
    |-----config
    |-----tsconfig.json
    |-----package.json

Any idea what I'm doing wrong?

All is in the title, trying to compile my TypeScript project to ./bin folder, the tsc commend execute without error resulting in nothing created, can't figure out why.

my tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
    "resolveJsonModule": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "lib": ["es6", "es7", "dom", "esnext"],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmit": true,
    "noImplicitAny": false,
    "outDir": "bin",
    "removeComments": true,
    "sourceMap": true,
    "target": "es2017",
    "rootDirs": ["src/", "config/"],
    "typeRoots": ["./node_modules/@types", "./typings"]
  },
  "include": ["src/**/*", "./typings"],
  "exclude": ["node_modules", "bin", "**/__mocks__*", "**/*.spec.**", "test", "assets"]
}

In my package.json this is my scripts to compile:

"scripts": {
    "build-ts": "tsc",
    "watch-ts": "tsc -w",
  },

the structure of my project:

rootdir
    |
    |-----src
    |      |----server.ts
    |      |----app.ts
    |-----test
    |-----node_modules
    |-----typings
    |-----config
    |-----tsconfig.json
    |-----package.json

Any idea what I'm doing wrong?

Another situation where TypeScript might not create a dist folder is when "incremental": true is set in compilerOptions in tsconfig.json , and you delete the dist folder without deleting the tsconfig.tsbuildinfo that keeps track of the incremental builds.

If you keep tsconfig.tsbuildinfo around and delete or modify dist , the compiler won't see a need to output anything, since tsconfig.tsbuildinfo is telling it that there's no work to do. The problem is the tsconfig.tsbuildinfo references an old state of dist .

Say your npm run clean command runs rimraf dist . You'll have to update it to also rimraf tsconfig.tsbuildinfo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM