deno 相对路径问题
deno relative path issue
我想为我的导入添加一些前缀,如下面的代码所示:
"paths": {
"~/*": ["../../libs/*"],
"@/*": ["./*"]
}
然而,当我尝试导入任何东西时,我总是得到 relative import path "@/config.ts" not prefixed with / or ./ or ../ts(10001)
import User from "@/config.ts"
您可以使用 import map. From the Deno manual:
为导入说明符设置别名
You can use import maps with the --import-map=<FILE>
CLI flag.
Example:
import_map.json
{
"imports": {
"fmt/": "https://deno.land/std@0.125.0/fmt/"
}
}
color.ts
import { red } from "fmt/colors.ts";
console.log(red("hello world"));
Then:
$ deno run --import-map=import_map.json color.ts
我想为我的导入添加一些前缀,如下面的代码所示:
"paths": {
"~/*": ["../../libs/*"],
"@/*": ["./*"]
}
然而,当我尝试导入任何东西时,我总是得到 relative import path "@/config.ts" not prefixed with / or ./ or ../ts(10001)
import User from "@/config.ts"
您可以使用 import map. From the Deno manual:
为导入说明符设置别名You can use import maps with the
--import-map=<FILE>
CLI flag.Example:
import_map.json
{ "imports": { "fmt/": "https://deno.land/std@0.125.0/fmt/" } }
color.ts
import { red } from "fmt/colors.ts"; console.log(red("hello world"));
Then:
$ deno run --import-map=import_map.json color.ts