Browse Source

Fix node cluster for nestjs (#7508)

* Fix node cluster for nestjs

* set esModuleInterop true for nestjs
JaeHyeok Kim 3 years ago
parent
commit
0f645e3166

+ 1 - 1
frameworks/TypeScript/nest/package.json

@@ -38,7 +38,7 @@
     "@nestjs/cli": "7.5.3",
     "@nestjs/schematics": "7.2.4",
     "@types/express": "4.17.3",
-    "@types/node": "13.7.7",
+    "@types/node": "16.11.46",
     "@typescript-eslint/eslint-plugin": "2.22.0",
     "@typescript-eslint/parser": "2.22.0",
     "eslint": "6.8.0",

+ 2 - 2
frameworks/TypeScript/nest/src/main.ts

@@ -8,7 +8,7 @@ import {
 import { MongoModule } from './mongo/mongo.module';
 import { join } from 'path';
 import { SqlModule } from './sql/sql.module';
-import cluster = require('cluster');
+import cluster from 'cluster'
 import os = require('os');
 
 const port = process.env.PORT || 8080;
@@ -57,7 +57,7 @@ async function bootstrapFastify() {
   await app.listen(8080, '0.0.0.0');
 }
 
-if (cluster.isMaster) {
+if (cluster.isPrimary) {
   const cpus = os.cpus().length;
   for (let i = 0; i < cpus; i++) {
     cluster.fork();

+ 2 - 1
frameworks/TypeScript/nest/tsconfig.json

@@ -10,7 +10,8 @@
     "outDir": "./dist",
     "baseUrl": "./",
     "incremental": true,
-    "skipLibCheck": true
+    "skipLibCheck": true,
+    "esModuleInterop": true
   },
   "include": ["src/**/*"],
   "exclude": ["node_modules", "dist"]