简体   繁体   English

npm run build 期间 docker build 中的 Typescript 错误

[英]Typescript error in docker build during npm run build

Facing a strange problem in docker build for typescript.在 docker build for typescript 中遇到一个奇怪的问题。

Docker file i have used as multistage build.我用作多阶段构建的 Docker 文件。

FROM node:13.12.0-alpine3.10 as build
COPY package.json /tmp/package.json
RUN cd /tmp && npm i --unsafe-perm --no-optional && npm cache clean --force

RUN mkdir -p /home/app && mkdir -p /home/app/ui && cp -a /tmp/node_modules /home/app && cp -a /tmp/ui/node_modules /home/app/ui/node_modules
WORKDIR /home/app
COPY . .
RUN npm run build && cd ui && npm run build

but the same works if i run npm run build in local machine instead of docker但如果我在本地机器上运行 npm run build 而不是 docker,同样有效

Error while running npm run build inside dockerfile在 dockerfile 中运行 npm run build 时出错

" error TS2322: Type 'Pick< ILocationValue, "address" | "_id" | "latitude" | "longitude" | "timezone" >' is not assignable to type 'ILocationValue'. " " 错误 TS2322: 类型 'Pick< ILocationValue, "address" | "_id" | "latitude" | "longitude" | "timezone" >' 不可分配给类型 'ILocationValue'。"

below is ILocationValue下面是 ILocationValue

interface ILocationValue extends MongoDoc, ILoc {} 

and

interface ILoc
{
    longitude: number;
    latitude: number;
    timezone: string;
    address: string;
}

Can someone help on this or if this docker related or TS related issue?有人可以帮助解决这个问题,或者这个 docker 相关或 TS 相关的问题吗?

Most probably you override node_modules while executing copy . .很可能您在执行copy . .覆盖了 node_modules copy . . copy . . with ones from your host.与您的主机。 Try running command on clean repository or add node_modules to docker ignore.尝试在干净的存储库上运行命令或将 node_modules 添加到 docker ignore。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM