Nest.Js- dist not generating with main.js file?

Viewed 453

I am facing an issue while running my project which consists of microservice setup in nestJs. I am running it using command npm start which is

"start": "tsc-watch -p tsconfig.build.json --onSuccess "node -r dotenv/config dist/main.js dotenv_config_path=../.env""

suddenly it stop updating my build code or reflecting changes on api behaivour. So, I tried rebuilding by dist using two commands that is

"build": "rimraf dist && tsc -p tsconfig.build.json",

now I am getting issue that build doesn't contain main.js file. I am getting following error-

throw err; ^

Error: Cannot find module 'D:\Nayana\Konnect Mojo\gitSetup\konnectmojo-web\backend\api-gateway\dist\main.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }

my package.json looks like this,

    {
"name": "api-gateway",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"prebuild": "rimraf dist",
"build": "rimraf dist && tsc -p tsconfig.build.json",
"format": "prettier --write "src//*.ts" "test//.ts"",
"start": "tsc-watch -p tsconfig.build.json --onSuccess "node -r dotenv/config dist/main.js dotenv_config_path=../.env"",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint "{src,apps,libs,test}/**/.ts" --fix",
"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"
},
"dependencies": {
"@nestjs/common": "^7.6.15",
"@nestjs/core": "^7.6.15",
"@nestjs/jwt": "^8.0.0",
"@nestjs/microservices": "^7.6.15",
"@nestjs/passport": "^8.0.0",
"@nestjs/platform-express": "^7.6.15",
"@nestjs/swagger": "^4.8.0",
"@nestjs/throttler": "^2.0.0",
"@skavinvarnan/cryptlib": "^1.0.3",
"dotenv": "^9.0.2",
"passport": "^0.4.1",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.6",
"swagger-ui-express": "^4.1.6"
},
"devDependencies": {
"@nestjs/cli": "^7.6.0",
"@nestjs/schematics": "^7.3.0",
"@nestjs/testing": "^7.6.15",
"@types/express": "^4.17.11",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.36",
"@types/passport": "^1.0.7",
"@types/supertest": "^2.0.10",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"supertest": "^6.1.3",
"ts-jest": "^26.5.4",
"ts-loader": "^8.0.18",
"ts-node": "^9.1.1",
"tsc-watch": "^4.2.9",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.2.3"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".\.spec\.ts$",
"transform": {
"^.+\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}

can anyone help me with this?

0 Answers
Related