首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Deno属性'utime‘在类型’类型Deno‘上不存在。等待Deno.utime(dest,statInfo.atime,statInfo.mtime);

Deno属性'utime‘在类型’类型Deno‘上不存在。等待Deno.utime(dest,statInfo.atime,statInfo.mtime);
EN

Stack Overflow用户
提问于 2020-05-10 21:55:55
回答 1查看 1.1K关注 0票数 3

我正在尝试使用标准的deno模块,但是编译器在没有--unstable标志的情况下发出了抱怨。

代码语言:javascript
复制
import { writeJson, readJson } from "https://deno.land/std/fs/mod.ts";

const json = await readJson("input.txt");
console.log(`JSON: ${JSON.stringify(json)}`);
await writeJson("input.txt", json);

我的deno版本:

代码语言:javascript
复制
deno 1.0.0-rc2
v8 8.4.300
typescript 3.8.3

我总是犯同样的错误。它们似乎与缺少的模块有关,但我不确定可能缺少什么。

代码语言:javascript
复制
➜  deno-api denoa filetest.ts 
Compile file:///home/astone/source/deno-api/filetest.ts
error: TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
    await Deno.utime(dest, statInfo.atime, statInfo.mtime);
               ~~~~~
    at https://deno.land/std/fs/copy.ts:90:16

TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
    Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
         ~~~~~~~~~
    at https://deno.land/std/fs/copy.ts:101:10

TS2339 [ERROR]: Property 'symlink' does not exist on type 'typeof Deno'.
  await Deno.symlink(originSrcFilePath, dest, type);
             ~~~~~~~
    at https://deno.land/std/fs/copy.ts:114:14

TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
    await Deno.utime(dest, statInfo.atime, statInfo.mtime);
               ~~~~~
    at https://deno.land/std/fs/copy.ts:119:16

TS2339 [ERROR]: Property 'symlinkSync' does not exist on type 'typeof Deno'.
  Deno.symlinkSync(originSrcFilePath, dest, type);
       ~~~~~~~~~~~
    at https://deno.land/std/fs/copy.ts:132:8

TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
    Deno.utimeSync(dest, statInfo.atime, statInfo.mtime);
         ~~~~~~~~~
    at https://deno.land/std/fs/copy.ts:137:10

TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'.
    await Deno.utime(dest, srcStatInfo.atime, srcStatInfo.mtime);
               ~~~~~
    at https://deno.land/std/fs/copy.ts:157:16

TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'.
    Deno.utimeSync(dest, srcStatInfo.atime, srcStatInfo.mtime);
         ~~~~~~~~~
    at https://deno.land/std/fs/copy.ts:185:10

TS2339 [ERROR]: Property 'link' does not exist on type 'typeof Deno'.
  await Deno.link(src, dest);
             ~~~~
    at https://deno.land/std/fs/ensure_link.ts:28:14

TS2339 [ERROR]: Property 'linkSync' does not exist on type 'typeof Deno'.
  Deno.linkSync(src, dest);
       ~~~~~~~~
    at https://deno.land/std/fs/ensure_link.ts:52:8

TS2339 [ERROR]: Property 'symlink' does not exist on type 'typeof Deno'.
  await Deno.symlink(src, dest, srcFilePathType);
             ~~~~~~~
    at https://deno.land/std/fs/ensure_symlink.ts:31:14

TS2339 [ERROR]: Property 'symlinkSync' does not exist on type 'typeof Deno'.
  Deno.symlinkSync(src, dest, srcFilePathType);
       ~~~~~~~~~~~
    at https://deno.land/std/fs/ensure_symlink.ts:58:8

Found 12 errors.

如果我只导入readJson模块,那么就不会出现错误。

代码语言:javascript
复制
import { readJson } from "https://deno.land/std/fs/read_json.ts";

我尝试使用标记构建,但我似乎找不出1.0.0-rc2的标记。我试过https://deno.land/std@0.50.0/fs/mod.ts

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-10 22:08:44

Deno.utime不稳定,这就是为什么要使用--unstable标志的原因。

还有一个悬而未决的问题:针对此错误的属性'utime‘在类型“Deno”中不存在

目前有多个不稳定标志后面的API。

从Deno 1.0.0开始,Deno命名空间API是稳定的。这意味着我们将努力使代码在1.0.0下继续工作在未来的版本中。 然而,德诺的所有功能还没有准备好生产。由于仍处于草稿阶段而尚未准备好的特性被锁定在--不稳定的命令行标志后面。

使用Deno.utime的文件是copy.ts & ensure_symlink.ts,这就是为什么如果您只加载read_json.ts就不会得到错误,并且不需要不稳定标志的原因。

std/的最新标记是std/0.50.0,但是始终可以将github直接引用到您想要的任何提交或发布标记。

代码语言:javascript
复制
https://raw.githubusercontent.com/denoland/deno/{tag}/std/fs/read_json.ts

因此,您可以在代码片段中使用以下内容:

代码语言:javascript
复制
import { readJson } from 'https://raw.githubusercontent.com/denoland/deno/v1.0.0-rc2/std/fs/read_json.ts'
import { writeJson } from 'https://raw.githubusercontent.com/denoland/deno/v1.0.0-rc2/std/fs/write_json.ts'
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61719244

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档