无法在另一个类的deno dep.ts文件中导入依赖项 [英] Unable to import dependency in deno dep.ts file in another class
本文介绍了无法在另一个类的deno dep.ts文件中导入依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在dep.ts文件中提到了依赖性,我想将引用导入另一个文件中.但是我收到以下错误.请帮我解决.我正在按照下面提到的链接进行操作.
I have mentioned the dependency in dep.ts file and I want to import the reference in another file. But I am getting the following error. Please help me to resolve. I was following the link as mentioned below.
https://deno.land/manual/linking_to_external_code#it-seems-unwieldy-to-import-urls-everywhere
我的简单代码在这里.
部门
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时,出现以下错误.
While executing the command deno run Test3.ts, I get the following error.
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)
推荐答案
error: Uncaught NotFound: Cannot resolve module
该错误表示您正在导入错误的文件(不存在).
That error means you're importing the wrong file (does not exist).
您要导入的是deps.ts
而不是dep.ts
除此之外,您想要做的是:
Aside from that, what you want is to:
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'
这篇关于无法在另一个类的deno dep.ts文件中导入依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文