【问题标题】:error: Import 'https://deno.land/std@v0.51.0/io/util.ts' failed: 404 Not Found错误:导入“https://deno.land/std@v0.51.0/io/util.ts”失败:404 Not Found
【发布时间】:2021-10-07 07:33:17
【问题描述】:

我收到以下错误消息,但我不知道程序的哪个部分导致此错误消息,因为我在我的应用程序中找不到这些库的直接导入:

deno run --allow-net --allow-read --allow-write --unstable server.ts
Download https://deno.land/std@v0.51.0/io/util.ts
Download https://deno.land/std@v0.51.0/io/bufio.ts
Warning std versions prefixed with 'v' were deprecated recently. Please change your import to https://deno.land/std@0.51.0/io/util.ts 
(at https://deno.land/std@v0.51.0/io/util.ts)
Warning std versions prefixed with 'v' were deprecated recently. Please change your import to https://deno.land/std@0.51.0/io/bufio.ts (at https://deno.land/std@v0.51.0/io/bufio.ts)
error: Import 'https://deno.land/std@v0.51.0/io/util.ts' failed: 404 Not Found
    at https://deno.land/x/dejs@0.7.0/vendor/https/deno.land/std/io/util.ts:1:0

有什么问题?如何找到并解决它?

【问题讨论】:

    标签: visual-studio-code import io deno


    【解决方案1】:

    使用 Deno 的 dependency inspector,您可以看到入口点模块中包含的所有依赖项的层次关系。像这样使用:

    deno info [OPTIONS] [URL or FILE_PATH]
    

    这里有一个例子来说明:

    在终端中:

    % ls
    deps.ts     mod.ts      test.ts     test_deps.ts
    
    % deno info test.ts
    local: /Users/deno/example/test.ts
    type: TypeScript
    emit: /Users/deno/.deno/gen/file/Users/deno/example/test.ts.js
    dependencies: 17 unique (total 107.24KB)
    
    file:///Users/deno/example/test.ts (284B)
    ├─┬ file:///Users/deno/example/mod.ts (308B)
    │ └─┬ file:///Users/deno/example/deps.ts (67B)
    │   └─┬ https://deno.land/std@0.110.0/path/mod.ts (725B)
    │     ├── https://deno.land/std@0.110.0/_util/os.ts (598B)
    │     ├── https://deno.land/std@0.110.0/path/_interface.ts (728B)
    │     ├─┬ https://deno.land/std@0.110.0/path/common.ts (1.16KB)
    │     │ └─┬ https://deno.land/std@0.110.0/path/separator.ts (259B)
    │     │   └── https://deno.land/std@0.110.0/_util/os.ts *
    │     ├─┬ https://deno.land/std@0.110.0/path/glob.ts (12.36KB)
    │     │ ├── https://deno.land/std@0.110.0/_util/os.ts *
    │     │ ├─┬ https://deno.land/std@0.110.0/path/posix.ts (14.49KB)
    │     │ │ ├── https://deno.land/std@0.110.0/path/_constants.ts (1.9KB)
    │     │ │ ├── https://deno.land/std@0.110.0/path/_interface.ts *
    │     │ │ └─┬ https://deno.land/std@0.110.0/path/_util.ts (3.62KB)
    │     │ │   ├── https://deno.land/std@0.110.0/path/_constants.ts *
    │     │ │   └── https://deno.land/std@0.110.0/path/_interface.ts *
    │     │ ├── https://deno.land/std@0.110.0/path/separator.ts *
    │     │ └─┬ https://deno.land/std@0.110.0/path/win32.ts (29.41KB)
    │     │   ├── https://deno.land/std@0.110.0/_util/assert.ts (405B)
    │     │   ├── https://deno.land/std@0.110.0/path/_constants.ts *
    │     │   ├── https://deno.land/std@0.110.0/path/_interface.ts *
    │     │   └── https://deno.land/std@0.110.0/path/_util.ts *
    │     ├── https://deno.land/std@0.110.0/path/posix.ts *
    │     ├── https://deno.land/std@0.110.0/path/separator.ts *
    │     └── https://deno.land/std@0.110.0/path/win32.ts *
    └─┬ file:///Users/deno/example/test_deps.ts (66B)
      └─┬ https://deno.land/std@0.110.0/testing/asserts.ts (20.63KB)
        ├── https://deno.land/std@0.110.0/fmt/colors.ts (11.53KB)
        └── https://deno.land/std@0.110.0/testing/_diff.ts (8.78KB)
    
    

    人为示例中模块的文本内容:

    deps.ts:

    export * as path from "https://deno.land/std@0.110.0/path/mod.ts";
    
    

    mod.ts:

    import { path } from "./deps.ts";
    
    const imageExtensions = new Set([
      "apng",
      "avci",
      "avif",
      "gif",
      "heic",
      "heif",
      "jpeg",
      "jpg",
      "png",
      "svg",
      "webp",
    ]);
    
    export function hasImageExtension(filePath: string): boolean {
      return imageExtensions.has(path.extname(filePath).slice(1));
    }
    
    

    test_deps.ts:

    export * from "https://deno.land/std@0.110.0/testing/asserts.ts";
    
    

    test.ts:

    import { assert } from "./test_deps.ts";
    import { hasImageExtension } from "./mod.ts";
    
    Deno.test("hasImageExtension", () => {
      let filePath = "./images/logo.png";
      assert(hasImageExtension(filePath));
      filePath = "./images/README.txt";
      assert(!hasImageExtension(filePath));
    });
    
    

    【讨论】:

      猜你喜欢
      • 2021-06-28
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      • 2020-05-28
      • 2019-12-10
      • 2019-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多