I have an EBS Instance with Platform Docker running on 64bit Amazon Linux/2.16.5
I have a nodejs typescript app which when uploaded needs to be compiled then run.
I get this error in /var/log/eb-docker/containers/eb-current-app/unexpected-quit.log
after downloading full logs.
Docker container quit unexpectedly on Thu Mar 11 02:12:43 UTC 2021:
> mybackend@1.0.0 start /usr/src/app
> node ./dist/server.js
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module '/usr/src/app/dist/server.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: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mybackend@1.0.0 start: `node ./dist/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mybackend@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/2021-03-11T02_12_39_040Z-debug.log
Dockerfile
FROM node:14-alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY tsconfig*.json ./
COPY src src
RUN npm run build
ENV NODE_ENV=ebs
ENV PORT=8080
ENV HOST=0.0.0.0
EXPOSE 8080
ENTRYPOINT ["npm", "start"]
package.json scripts
"scripts": {
"start": "node ./dist/server.js",
"build": "tsc",
"dev": "nodemon",
"test": "jest --watch"
},
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"outDir": "dist",
"sourceMap": true,
"strict": true,
"target": "es2017",
"allowSyntheticDefaultImports": true,
"noImplicitAny": false
},
"compileOnSave": true,
"include": [
"src/",
]
}
This works fine locally on my ubuntu machine using docker. It only fails on ebs instance.