I updated my projecto Angular 17.1 and now when i try ng build it creates a server.mjs file in /dist//server directory which is meant to be served for production. when I try to run the file with node or pm2 i get the following error
TypeError: Nl is not a function
at $C (file:///Users/goldenfox/Projects/front/dist/karlancer/server/server.mjs:106:5771)
at GC (file:///Users/goldenfox/Projects/front/dist/karlancer/server/server.mjs:106:6227)
at file:///Users/goldenfox/Projects/front/dist/karlancer/server/server.mjs:106:6318
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v20.11.0
Any Idea about how I can fix this ?
Setting optimization flag to false helped me find out that the problem was importing import express from 'express';
in server.ts file, This package needs setting this flag "allowSyntheticDefaultImports": true
in angularCompilerOptions of tsconfing.json in Angular 17.