我正在尝试使用标准 deno fs 模块,但编译器抱怨没有--unstable
标志。
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 版本:
deno 1.0.0-rc2
v8 8.4.300
typescript 3.8.3
我总是遇到同样的错误。它们似乎与缺少的模块有关,但我不确定可能缺少什么。
➜ 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 模块,那么我不会收到错误。
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
。