【发布时间】:2021-12-23 08:32:15
【问题描述】:
我第一次尝试在个人项目中使用 Deno,但遇到了这个我似乎无法解决的问题。每当我添加一个新的导入语句时,我都会遇到同样的错误,类似于:
error: Uncaught SyntaxError: The requested module 'https://deno.land/std/uuid/mod.ts' does not provide an export named 'v4'
不过,无论何时查看模块,您都可以看到正在导出“v4”:
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// Based on https://github.com/kelektiv/node-uuid -> https://www.ietf.org/rfc/rfc4122.txt
// Supporting Support for RFC4122 version 1, 4, and 5 UUIDs
import * as v1 from "./v1.ts";
import * as v4 from "./v4.ts";
import * as v5 from "./v5.ts";
export const NIL_UUID = "00000000-0000-0000-0000-000000000000";
/**
* Check if the passed UUID is the nil UUID.
*
* ```js
* import { isNil } from "./mod.ts";
*
* isNil("00000000-0000-0000-0000-000000000000") // true
* isNil(crypto.randomUUID()) // false
* ```
*/
export function isNil(id: string): boolean {
return id === NIL_UUID;
}
export { v1, v4, v5 };
在我的代码中,这是我的导入语句:
import { v4 } from "https://deno.land/std/uuid/mod.ts";
这也是本文导入它的方式https://medium.com/deno-the-complete-reference/all-about-uuids-in-deno-b8d04ce96535
有人知道这里会发生什么吗?我已经完成了deno cache --reload,但这似乎并不能解决我的问题。另外,如果有影响的话,我正在使用带有 Deno 插件的 WebStorm。
谢谢!
编辑:另外,我正在使用以下参数运行 deno:
deno run --allow-all --unstable
【问题讨论】:
-
尝试像这样导入它:
import {v4 as uuidv4} -
@InsalataCondita 当我使用导入
import {v4 as uuidv4} from "https://deno.land/std/uuid/mod.ts";时出现以下错误:error: Uncaught SyntaxError: The requested module 'https://deno.land/std/uuid/mod.ts' does not provide an export named 'v4' import {v4 as uuidv4} from "https://deno.land/std/uuid/mod.ts"; -
您是否缓存了该库的旧版本?我刚刚尝试了标准库的 0.114.0 版本,并且导入按预期工作
标签: typescript import deno