Mohammad ARZ
Mohammad ARZ

Reputation: 171

Unexpected token 'export' Observable when nest build

I am trying to dockerize my application but I get this error only when running the container and not on my local machine I am using SWC Compiler on Nestjs here is my dockerfile

FROM node:18.19.1-alpine

ENV NODE_ENV build

USER node
WORKDIR /home/node

COPY package*.json ./
COPY node_modules ./  
# RUN npm ci

COPY --chown=node:node . .
CMD npx prisma generate \
    && npm run build \
    && node dist/main

error

> [email protected] build
> nest build

>  SWC  Running...
Successfully compiled: 259 files with swc (169.92ms)
/home/node/rxjs/dist/esm5/index.js:1
export { Observable } from './internal/Observable';
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1274:20)
    at Module._compile (node:internal/modules/cjs/loader:1320:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/home/node/dist/core/interceptors/timeout.interceptor.js:13:15)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)

Node.js v18.19.1

Upvotes: 0

Views: 23

Answers (1)

Mohammad ARZ
Mohammad ARZ

Reputation: 171

dont copy the node_modules but rather npm ci

Upvotes: 0

Related Questions