W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
Deno 提供一組標(biāo)準(zhǔn)模塊,它們經(jīng)過核心團(tuán)隊(duì)審計(jì),保證能在 Deno 上工作。 標(biāo)準(zhǔn)庫地址:https://deno.land/std/
標(biāo)準(zhǔn)庫尚不穩(wěn)定,因此采用與 Deno 不同的版本號。每次 Deno 發(fā)布時(shí),標(biāo)準(zhǔn)庫也會一起發(fā)布。 最新的發(fā)布請查閱 https://deno.land/std/ 或 https://deno.land/std/version.ts。 我們強(qiáng)烈建議:始終使用確定版本的標(biāo)準(zhǔn)庫,以避免意外的改動。 例如,連接到隨時(shí)可能更改的主分支時(shí)可能會導(dǎo)致編譯錯(cuò)誤或意外行為:
// 從 master 導(dǎo)入,這應(yīng)當(dāng)避免
import { copy } from "https://deno.land/std/fs/copy.ts";
更好的選擇是使用不可變且不會更改的 std 庫版本:
// 從不可變的 std v0.50.0 導(dǎo)入
import { copy } from "https://deno.land/std@0.50.0/fs/copy.ts";
標(biāo)準(zhǔn)庫中的一些模塊使用了不穩(wěn)定的 Deno API。 不用 --unstable 命令行選項(xiàng)運(yùn)行這些模塊會產(chǎn)生一些 TypeScript 錯(cuò)誤,表示 Deno 命名空間中不存在一些 API:
// main.ts
import { copy } from "https://deno.land/std@0.50.0/fs/copy.ts";
copy("log.txt", "log-old.txt");
$ deno run --allow-read --allow-write main.ts
Compile file:///dev/deno/main.ts
Download https://deno.land/std@0.50.0/fs/copy.ts
Download https://deno.land/std@0.50.0/fs/ensure_dir.ts
Download https://deno.land/std@0.50.0/fs/_util.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@0.50.0/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@0.50.0/fs/copy.ts:101:10
解決方法是加上--unstable
選項(xiàng):
deno run --allow-read --allow-write --unstable main.ts
要確定哪些 API 是不穩(wěn)定的,請查閱類型聲明 lib.deno.unstable.d.ts
這個(gè)問題會在不遠(yuǎn)的將來解決。如果您依賴的特定模塊在沒有該選項(xiàng)的情況下成功編譯,則可以忽略該選項(xiàng)。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: