当使用命令运行应用程序时deno run app.ts,它给出一个error: Uncaught PermissionDenied
error: Uncaught PermissionDenied: access to environment variables, run again with the --allow-env flag
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendSync ($deno$/ops/dispatch_json.ts:72:10)
at Object.toObject ($deno$/ops/os.ts:33:12)
at file:///opt//deno/app.ts:5:22
Run Code Online (Sandbox Code Playgroud)
这种类型的问题我们需要在运行应用程序时设置一个标志
不同类型的权限
--allow-env
Allow environment access
--allow-hrtime
Allow high resolution time measurement
--allow-net=<allow-net>
Allow network access
--allow-plugin
Allow loading plugins
--allow-read=<allow-read>
Allow file system read access
--allow-run
Allow running subprocesses
--allow-write=<allow-write>
Allow file system write access
deno run -allow-all app.ts
Run Code Online (Sandbox Code Playgroud)
例子
//Give an environment permission
deno run --allow-env app.ts
//Give an all permission
deno run -allow-all app.ts
OR
deno run -A app.ts
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1912 次 |
| 最近记录: |