I maintain an old application running on docker using image FROM node:12.22.7
.
Since this is an old application, it can only use specific version of npm packages.
I use docker in my Mac and Windows without issue. But the issue arises when deploying it to server using RHEL 9.
This error log only occurs on the server:
error: uncaughtException: Unexpected token '?'
The package related is: “excel4node”: “^1.7.2” with dependencies to “image-size”
I looked up similar issue in (How to solve error “SyntaxError: Unexpected token ‘?'”) it was caused by old node version 12, and need to upgrade to 14.
When I tried to update the image to 14 or later, that error disappeared, but it leads to another problem as I stated previously this is an old application and need to update more packages and application codes.
It can work on my local environment, but not in the server.
The difference between my local and the server is swarm mode, I only have it active on the server.
Here is the Dockerfile I use:
# Using latest Node.js image
FROM node:12.22.7
# Set environment variable during build process
ARG DOCKER_ENV
ENV NODE_ENV "$DOCKER_ENV"
# Copy depedency
ADD package.json /usr/src/app/
# Create app directory
WORKDIR /usr/src/app
# Install depedency
RUN npm install
# Bundle app source
COPY . .
ENV HOST 0.0.0.0
EXPOSE 9000
CMD [ "node", "--max-old-space-size=4096", "app.js" ]