首页 > 解决方案 > 错误:尝试将不支持的媒体类型作为模块导入

问题描述

这是我的deps.ts文件:

deps.ts:

export {
  Application,
  Router,
  Context,
  send,
} from "https://deno.land/x/oak@v9.0.1/mod.ts";
export type { RouterContext } from "https://deno.land/x/oak@v9.0.1/mod.ts";
export { MongoClient } from "https://deno.land/x/mongo@v0.27.0/mod.ts";
export {
  hashSync,
  compareSync,
} from "https://deno.land/x/bcrypt@v0.2.4/mod.ts";
import "https://deno.land/x/dotenv@v3.0.0/load.ts";
export { create, verify, decode, getNumericDate,  }  from "https://deno.land/x/djwt@v2.4/mod.ts";

这是我认为错误来自的代码的一部分:

auth_controller.ts:

import {
  create, verify, decode, getNumericDate, RouterContext, hashSync, compareSync
} from "../deps.ts";
import { userCollection } from "../mongo.ts";
import User from "../models/user.ts";

这是我收到的错误消息:

错误:尝试将不支持的媒体类型作为模块导入。说明符:file:///C:/NewP/app_back/controllers/auth_controller 媒体类型:未知

标签: importmediadeno

解决方案


我发现在其他应用程序文件之一中,我导入auth_controller了没有.ts扩展名的文件。我.ts在该导入行的末尾添加了扩展名,问题解决了。


推荐阅读