I am deploying a Docker Image to EKS and in doing so get a Babel parse error despite the build running without error on my local machine. Both build attempts use the same code and Dockerfile.
build 28-Jan-2022 14:06:57 > npm run clean && babel ./ --out-dir dist
build 28-Jan-2022 14:06:57
build 28-Jan-2022 14:06:58
build 28-Jan-2022 14:06:58 > ESGDA_API@1.0.0 clean /app
build 28-Jan-2022 14:06:58 > rm -rf ./dist && mkdir dist
build 28-Jan-2022 14:06:58
build 28-Jan-2022 14:07:02 [91mSyntaxError: /app/.scannerwork/css- bundle/node_modules/@babel/core/src/config/files/index-browser.js: Unexpected token (3:12)
build 28-Jan-2022 14:07:02
build 28-Jan-2022 14:07:02 1 | // @flow
build 28-Jan-2022 14:07:02 2 |
build 28-Jan-2022 14:07:02 > 3 | import type { Handler } from "gensync";
build 28-Jan-2022 14:07:02 | ^
My babel.config.json looks like so;
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
},
"include": ["@babel/plugin-transform-spread"]
}
]
],
"plugins": [
"@babel/plugin-transform-spread"
],
"ignore": [
"node_modules"
]
}
My package.json file portion with Babel specs looks like so, including scripts;
"scripts": {
"build": "npm run clean && babel ./ --out-dir dist",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon --exec babel-node index.js",
"clean": "rm -rf ./dist && mkdir dist",
"clean-install": "rm -rf node_modules && rm package-lock.json && npm i"
}
"devDependencies": {
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"@babel/node": "^7.15.4",
"@babel/preset-env": "^7.15.6"
}
The Dockerfile up until the point of the error looks as follows;
FROM node:14.17.6-alpine AS base
WORKDIR /app
FROM base AS builder
COPY package*.json babel.config.json ./
RUN npm ci
COPY . .
RUN npm run build
I'm hoping to understand how the same code and Dockerfile could be erroring out in one environment but not the other. Any insight is much appreciated and please let me know what more information I can provide, thanks.