Deno is secure by default. Therefore, unless you specifically enable it, a deno module has no file, network, or environment access for example. Access to security-sensitive areas or functions requires the use of permissions to be granted to a deno process on the command line.
--allow-net
才能順利執行:在該系列文中,旗標跟子命令的意思是相同的,只是筆者不知道該用哪個形容會更好 XD
--allow-net
以外, Deno 官方文件上還有提供詳細的列表:筆者不建議這麼做,因為使用它便失去 Sandbox 機制的意義了。
需要注意的是,--allow-plugin
是一個不穩定的功能,所以還需要加上--unstable
標籤。舉例:deno run --allow-plugin --unstable main.ts
需要注意的是,由主進程開啟的子進程沒有在 sandbox 機制中運行,因此沒有與 deno 進程一樣具有相同的安全限制。必須謹慎使用。
同樣的事情在不同人眼中可能會有不同的見解、看法。在讀完本篇以後,筆者也強烈建議大家去看看以下文章,或許會對型別、變數宣告...等觀念有更深層的看法唷!