I am trying to use the standard deno fs module but the compiler complains without the --unstable flag.
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);
My deno version:
deno 1.0.0-rc2
v8 8.4.300
typescript 3.8.3
I always get the same errors. They seem to be related to missing modules but I'm not sure what could be missing.
➜ 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.
If I only import the readJson module then I don't get errors.
import { readJson } from "https://deno.land/std/fs/read_json.ts";
I tried using a tag build but I can't seem to figure out the tag for 1.0.0-rc2. I tried https://deno.land/[email protected]/fs/mod.ts.
Deno.utime has been marked unstable, which is the reason why you should use --unstable flag
There's also an open issue: Property 'utime' does not exist on type 'typeof Deno' for this error.
Currently there are multiple APIs which are behind the unstable flag.
As of Deno 1.0.0, the Deno namespace APIs are stable. That means that we will strive to make code working under 1.0.0 continue to work in future versions.
However, not all of Deno's features are ready for production yet. Features which are not ready because they are still in draft phase are locked behind the --unstable command line flag.
The files that are using Deno.utime are copy.ts & ensure_symlink.ts which is the reason why if you only load read_json.ts you don't get that error, and don't need the unstable flag.
The latest tag for std/ is std/0.50.0 but you can always reference the github repo directly to whatever commit or release tag you want.
https://raw.githubusercontent.com/denoland/deno/{tag}/std/fs/read_json.ts
So you can use the following for your snippet:
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With