我正在尝试对我的应用程序进行 dockerize,但仅在运行容器时才会出现此错误,而不是在本地计算机上我在 Nestjs 上使用 SWC 编译器 这是我的 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
错误
> [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
不要复制node_modules 而是 npm ci