I have NestJs API service and it's run very well when it runs using "npm run dev" command. but when I dockerized, it failed to run the app. I tried node versions 9,10 and 12 also with the container. but it runs smoothly with node version 9 in my computer using run dev command.
I'm using docker run -it -p 9000:3001 dev-service
to run container. the error is below.
nestjs-sample-api@1.0.0 start /app
> node index.js "prod"
TypeError: Cannot read property 'constructor' of undefined
at Object.<anonymous> (/app/node_modules/cli-highlight/src/theme.ts:4:26)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/ts-node/src/index.ts:406:14)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/app/node_modules/cli-highlight/src/index.ts:3:1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nestjs-sample-api@1.0.0 start: `node index.js "prod"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nestjs-sample-api@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-15T03_20_53_617Z-debug.log
Docker File:
ROM node:9
WORKDIR /app
COPY package.json /app
COPY ormconfig.json /app
RUN npm install
COPY . /app
COPY ormconfig.json /dist/
CMD ["npm", "start", "prod" ]