user1688181
user1688181

Reputation: 494

Nest JS build does does not generate the dist folder

I have implemented rest api project with nest js.it is working fine on local environment.(pm start)

I want to build it and deploy. but build command does not generate the dust folder. following is my configurations

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es6",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "allowJs": true,
    "checkJs": true, 
    "noEmit": true
  },
  "exclude": ["node_modules"],
  "paths": {
    "@app/*": ["src/*"],
    "@test/*": ["test/*"]
  }
}

package.json

 "scripts": {
    "build": "tsc -p tsconfig.build.json",
    "format": "prettier --write \"src/**/*.ts\"",
    "start": "npm run start:prod",
    "start:dev": "concurrently --handle-input \"wait-on dist/main.js && nodemon\" \"tsc -w -p tsconfig.build.json\" ",
    "start:prod": "node dist/src/main.js",
    "lint": "tslint -p tsconfig.json -c tslint.json",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json",
    "gcp-build": "npm run build"
  }

when I execute the npm run build nothing happens. no errors. no dist folder. can any one help me to fix this issue?

Upvotes: 8

Views: 25796

Answers (2)

michael
michael

Reputation: 270

Had the same issue, the problem is TS compiler won't generate /dist (compile JS to TS) if there're some .tsbuildinfo files (when incremental option is on).

So, basically what you need to do is remove all .tsbuildinfo files before you build the project.

Or simply turn off the incremental and noEmit options in your tsconfig.json:

"noEmit": false       // <- remove this or set to false
"incremental": false, // <- remove this or set to false

Upvotes: 25

user1688181
user1688181

Reputation: 494

Once I update the typescript version into 3.7.2 in package.json file, dist folder generated.previously it was 3.4.1

"typescript": "3.7.2",

Upvotes: 0

Related Questions