由于docker build中的TypeScript错误,npm run build失败

好奇的人
Failed to compile.

/app/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts
TypeScript error in /app/node_modules/@ant-design/icons/lib/components/AntdIcon.d.ts(2,13):
'=' expected.  TS1005

  1 | import * as React from 'react';
> 2 | import type { IconDefinition } from '@ant-design/icons-svg/lib/types';
  |             ^
  3 | import type { IconBaseProps } from './Icon';
  4 | import { getTwoToneColor, TwoToneColor, setTwoToneColor } from './twoTonePrimaryColor';
  5 | export interface AntdIconProps extends IconBaseProps {

我的package.json

{
  "name": "web",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@types/react-native-fetch-blob": "^0.10.5",
    "@types/react-select": "^3.0.16",
    "@types/rn-fetch-blob": "^1.2.1",
    "antd": "^4.2.4",
    "common-tags": "^1.8.0",
    "lodash": "^4.17.19",
    "moment": "^2.26.0",
    "node-sass": "^4.13.1",
    "normalize.css": "^8.0.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-redux": "^7.2.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "socket.io-client": "^2.3.0",
    "typescript": "~3.7.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "storybook": "start-storybook -p 9000 -c .storybook"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@storybook/addon-actions": "^5.3.18",
    "@storybook/addon-info": "^5.3.18",
    "@storybook/addon-knobs": "^5.3.18",
    "@storybook/addon-notes": "^5.3.18",
    "@storybook/addons": "^5.3.18",
    "@storybook/preset-create-react-app": "^2.1.2",
    "@storybook/react": "^5.3.18",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/common-tags": "^1.8.0",
    "@types/jest": "^24.0.0",
    "@types/lodash": "^4.14.150",
    "@types/node": "^12.0.0",
    "@types/react": "^16.9.0",
    "@types/react-dom": "^16.9.0",
    "@types/react-redux": "^7.1.7",
    "@types/react-router-dom": "^5.1.4",
    "@types/redux": "^3.6.0",
    "@types/socket.io-client": "^1.4.32",
    "babel-loader": "8.1.0",
    "react-docgen-typescript-loader": "^3.7.2"
  }
}

我的Dockerfile

FROM node:12 as builder

WORKDIR /app

COPY package.json .
RUN npm install
COPY . ./
RUN npm run build

FROM nginx:stable
COPY --from=builder /app/build /usr/share/nginx/html

谷歌搜索了这个问题之后才知道https://github.com/ant-design/ant-design/issues/23266#issuecomment-613773502 you need update @types/react。我尝试了"@types/react" : "17.0.1"但是没有帮助。

Filip Seman |

Antdv4.2.4使用TypeScript v3.9.2

import type从TypeScript开始,支持编译器抱怨的功能v3.8

大多数用户可能不必考虑此功能。但是,如果您遇到--isolatedModules,TypeScript的transpileModule API或Babel下的问题,则此功能可能是相关的。

import type { SomeThing } from "./some-module.js";
export type { SomeThing };

来源:https : //www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html

将本地TypeScript版本从更新v3.7.2为atleast v3.8

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Cordova android run / build错误-对JDK 1.8的要求检查失败

由于minSDK版本,Phonegap Create和Build命令失败

Docker dm_task_run失败错误

什么是“ npm run -s build”中的“ -s”

运行“ npm run build”后收到npm错误:npm ERR!代码ELIFECYCLE npm ERR!错误2

Travis Build因docker push而失败

NG Build在Azure Pipelines中失败,出现NPM错误134

使用Webpack运行npm run build时反应Typescript错误

“ npm run build”失败,并出现SyntaxError:Unexpected token

来自npm-run-build前端的Django中的静态文件抛出错误404

docker撰写aspnetcore build vs dotnet run

连接到docker build中的dotnet.testcontainer失败,并显示消息“无法分配请求的地址/var/run/docker.sock”

docker build在“下载mariadb”时失败

使用kaniko缓存运行docker build时,不缓存npm run build

Docker容器中的安装脚本由于xz命令而失败

由于捆绑程序导致黄瓜在Docker容器中失败

在Docker中安装build-essential失败

在Windows 7上运行npm start或npm run build时,skeleton-typescript-webpack失败

`sudo docker build .` Docker snap 包失败

由于库版本不兼容,Android Build 执行失败

运行 DOCKER BUILD 时 COPY 命令失败

pip install 在 docker build 上失败

如何防止 npm run build 删除 build 中的目录

在 npm run build 之前检查 jshint 错误

运行“npm run build”时出现 npm run build 错误

npm run build 失败:语法错误:TypeError:无法读取未定义的属性“parseComponent”

React Native run-android Build 失败

npm run build gatsby:“来自 page-data.json 的页面数据,用于失败页面“/404/”...”

由于 gcc 错误,Python docker 映像构建失败