无法在另一个 class 的 deno dep.ts 文件中导入依赖项
Unable to import dependency in deno dep.ts file in another class
我在 dep.ts 文件中提到了依赖项,我想在另一个文件中导入引用。但是我收到以下错误。请帮我解决。我正在关注下面提到的 link。
https://deno.land/manual/linking_to_external_code#it-seems-unwieldy-to-import-urls-everywhere
这里是我的简单代码。
dep.ts
export {
log
} from "https://deno.land/std/log/mod.ts";
Test3.ts
import { log } from "./dep.ts";
export class Test3 {
public show() {
log.debug("Exploring deno ...");
}
}
const test = new Test3();
test.show();
在执行命令 deno 运行 Test3.ts 时,出现以下错误。
error: Uncaught NotFound: Cannot resolve module "file:///C:/javascriptdev1/deno-test1/deps.ts" from "file:///C:/javascriptdev1/deno-test1/Test3.ts"
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
at async processImports ($deno$/compiler.ts:736:23)
at async processImports ($deno$/compiler.ts:753:7)
at async compile ($deno$/compiler.ts:1316:31)
at async tsCompilerOnMessage ($deno$/compiler.ts:1548:22)
at async workerMessageRecvCallback ($deno$/runtime_worker.ts:74:9)
您正在从 "deps.ts" 导入,但文件名为 "dep.ts"。确保所有内容都拼写正确。
error: Uncaught NotFound: Cannot resolve module
该错误意味着您导入了错误的文件(不存在)。
您正在导入 deps.ts
而不是 dep.ts
除此之外,您想要的是:
export * as log from "https://deno.land/std/log/mod.ts";
// you can have other exports too
export {
assert,
assertEquals,
assertStrContains,
} from "https://deno.land/std/testing/asserts.ts";
否则你会得到:
Module '"./deps"' has no exported member 'log'
我在 dep.ts 文件中提到了依赖项,我想在另一个文件中导入引用。但是我收到以下错误。请帮我解决。我正在关注下面提到的 link。
https://deno.land/manual/linking_to_external_code#it-seems-unwieldy-to-import-urls-everywhere
这里是我的简单代码。
dep.ts
export {
log
} from "https://deno.land/std/log/mod.ts";
Test3.ts
import { log } from "./dep.ts";
export class Test3 {
public show() {
log.debug("Exploring deno ...");
}
}
const test = new Test3();
test.show();
在执行命令 deno 运行 Test3.ts 时,出现以下错误。
error: Uncaught NotFound: Cannot resolve module "file:///C:/javascriptdev1/deno-test1/deps.ts" from "file:///C:/javascriptdev1/deno-test1/Test3.ts"
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
at async processImports ($deno$/compiler.ts:736:23)
at async processImports ($deno$/compiler.ts:753:7)
at async compile ($deno$/compiler.ts:1316:31)
at async tsCompilerOnMessage ($deno$/compiler.ts:1548:22)
at async workerMessageRecvCallback ($deno$/runtime_worker.ts:74:9)
您正在从 "deps.ts" 导入,但文件名为 "dep.ts"。确保所有内容都拼写正确。
error: Uncaught NotFound: Cannot resolve module
该错误意味着您导入了错误的文件(不存在)。
您正在导入 deps.ts
而不是 dep.ts
除此之外,您想要的是:
export * as log from "https://deno.land/std/log/mod.ts";
// you can have other exports too
export {
assert,
assertEquals,
assertStrContains,
} from "https://deno.land/std/testing/asserts.ts";
否则你会得到:
Module '"./deps"' has no exported member 'log'