我正在try 运行 docker 文件本地化( node 类型脚本上的项目)

docker 文件

FROM node:20-alpine

EXPOSE 5000
MAINTAINER Some Dev

RUN mkdir /app
WORKDIR /app

COPY ./backend/* /app

RUN npm i

CMD ["npm","start"]

但我遇到了一个问题错误TS 18003:在配置文件"/app/tsmin.json"中找不到输入.指定的"包含"路径是"["./ SRC/","./ src/** /.ts","./src/.ts"]"和"排除"路径为"["./ dist"".

Tsconfig.json

{
  "compilerOptions": {
    "target": "ES2021",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
    "module": "commonJS",                                /* Specify what module code is generated. */
    "moduleResolution": "node",                          /* Specify how TypeScript looks up a file from a given module specifier. */
    "rootDir": "./src",/* Specify the root folder within your source files. */
    "outDir": "./dist",                                  /* Specify an output folder for all emitted files. */
    "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
    "allowSyntheticDefaultImports": true,                /* Allow 'import x from y' when a module doesn't have a default export. */
    "removeComments": true,                              /* Disable emitting comments. */
    "noImplicitAny": true,                               /* Enable error reporting for expressions and declarations with an implied 'any' type. */
    "noUnusedLocals": true,                              /* Enable error reporting when local variables aren't read. */
    "skipLibCheck": true
  },
  "include": [
    "./src/",
    "./src/**/*.ts",
    "./src/*.ts"
  ],
  "exclude": [
    "./dist"
  ]
}

My folders My folders

在包括、排除中try 了一些不同的事情.看到建议添加空ts文件并创建,但没有任何变化.重新启动IDE(FieldJ idea ).

推荐答案

当项目内部没有.ts文件时,会发生此错误.发生这种情况是因为/src文件夹不会复制到/app,因为 * 只复制目录内的文件而不是子目录内的文件.将COPY ./backend/* /app更改为COPY ./backend /app.

Node.js相关问答推荐

nest js控制器方法调用两次

从MongoDB获取Tree数据

关于Node.js中的AES加密库的问题

创建查询以展开数组并筛选出具有特定值的元素之后的元素

如何创建具有不同对象类型的数组类型

Redis Typescript 删除方法类型转换

在全局对象上声明的函数

无法通过 NextJS 访问 HTTP 帖子中的正文

Typescript :泛型类又扩展了另一个泛型类

如何获取文件的中间值?

如何配置 Nginx React 和 Express

如何使用 Remix 仅在客户端呈现组件?

kubernetes 上的 nextjs 无法启动

mongoose.model() 方法返回未定义

使用 WebSockets 有服务器成本吗?

在本地运行 Cloud Functions 会出现错误functions.config() 不可用

如何监控 node.js 上的网络,类似于 chrome/firefox 开发者工具?

已安装全局 NPM 包但未找到命令

如何解决'npm应该在 node repl之外运行,在你的普通shell中'

按日期时间字段获取最新的 MongoDB 记录