I get the following error message but I don't know which part of the program causes this error message because I can not find a direct importing of these libraries in my app:
deno run --allow-net --allow-read --allow-write --unstable server.ts
Download https://deno.land/[email protected]/io/util.ts
Download https://deno.land/[email protected]/io/bufio.ts
Warning std versions prefixed with 'v' were deprecated recently. Please change your import to https://deno.land/[email protected]/io/util.ts
(at https://deno.land/[email protected]/io/util.ts)
Warning std versions prefixed with 'v' were deprecated recently. Please change your import to https://deno.land/[email protected]/io/bufio.ts (at https://deno.land/[email protected]/io/bufio.ts)
error: Import 'https://deno.land/[email protected]/io/util.ts' failed: 404 Not Found
at https://deno.land/x/[email protected]/vendor/https/deno.land/std/io/util.ts:1:0
What is the problem? How can I find and resolve it?
CodePudding user response:
Using Deno's dependency inspector, you can see a hierarchical relationship of all dependencies included in your entrypoint module. Use like this:
deno info [OPTIONS] [URL or FILE_PATH]
Here's an example to illustrate:
In the terminal:
% 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/[email protected]/path/mod.ts (725B)
│ ├── https://deno.land/[email protected]/_util/os.ts (598B)
│ ├── https://deno.land/[email protected]/path/_interface.ts (728B)
│ ├─┬ https://deno.land/[email protected]/path/common.ts (1.16KB)
│ │ └─┬ https://deno.land/[email protected]/path/separator.ts (259B)
│ │ └── https://deno.land/[email protected]/_util/os.ts *
│ ├─┬ https://deno.land/[email protected]/path/glob.ts (12.36KB)
│ │ ├── https://deno.land/[email protected]/_util/os.ts *
│ │ ├─┬ https://deno.land/[email protected]/path/posix.ts (14.49KB)
│ │ │ ├── https://deno.land/[email protected]/path/_constants.ts (1.9KB)
│ │ │ ├── https://deno.land/[email protected]/path/_interface.ts *
│ │ │ └─┬ https://deno.land/[email protected]/path/_util.ts (3.62KB)
│ │ │ ├── https://deno.land/[email protected]/path/_constants.ts *
│ │ │ └── https://deno.land/[email protected]/path/_interface.ts *
│ │ ├── https://deno.land/[email protected]/path/separator.ts *
│ │ └─┬ https://deno.land/[email protected]/path/win32.ts (29.41KB)
│ │ ├── https://deno.land/[email protected]/_util/assert.ts (405B)
│ │ ├── https://deno.land/[email protected]/path/_constants.ts *
│ │ ├── https://deno.land/[email protected]/path/_interface.ts *
│ │ └── https://deno.land/[email protected]/path/_util.ts *
│ ├── https://deno.land/[email protected]/path/posix.ts *
│ ├── https://deno.land/[email protected]/path/separator.ts *
│ └── https://deno.land/[email protected]/path/win32.ts *
└─┬ file:///Users/deno/example/test_deps.ts (66B)
└─┬ https://deno.land/[email protected]/testing/asserts.ts (20.63KB)
├── https://deno.land/[email protected]/fmt/colors.ts (11.53KB)
└── https://deno.land/[email protected]/testing/_diff.ts (8.78KB)
The text contents of the modules in the contrived example:
deps.ts
:
export * as path from "https://deno.land/[email protected]/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/[email protected]/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));
});