Error: An unsupported media type was attempted to be imported as a module
Error: An unsupported media type was attempted to be imported as a module
这是我的 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";
这是我收到的错误消息:
error: An unsupported media type was attempted to be imported as a
module. Specifier:
file:///C:/NewP/app_back/controllers/auth_controller MediaType:
Unknown
我发现我在其他应用程序文件之一中导入了 auth_controller
没有 .ts
扩展名的文件。我在该导入行的末尾添加了 .ts
扩展名,问题得到解决。
这是我的 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";
这是我收到的错误消息:
error: An unsupported media type was attempted to be imported as a module. Specifier: file:///C:/NewP/app_back/controllers/auth_controller MediaType: Unknown
我发现我在其他应用程序文件之一中导入了 auth_controller
没有 .ts
扩展名的文件。我在该导入行的末尾添加了 .ts
扩展名,问题得到解决。