error: Failed to get compiled source code of https://deno.land/std@0.59.0/path/mod.ts. Reason: The system cannot find the path specified. (os error 3)

error: Failed to get compiled source code of https://deno.land/std@0.59.0/path/mod.ts. Reason: The system cannot find the path specified. (os error 3)

在 运行 我的 main.ts 文件 deno 之后,我得到这个错误:

error: Failed to get compiled source code of https://deno.land/std@0.59.0/path/mod.ts.
Reason: The system cannot find the path specified. (os error 3)

我 运行 我的文件使用此命令:deno run --allow-net main.ts 我也试过 deno run --allow-net --allow-read main.ts 但出现同样的错误。

我的 main.ts 文件:

// Requiring modules 
import { Application, Router,send } from "https://deno.land/x/oak/mod.ts";
import {viewEngine,engineFactory,
adapterFactory} from "https://deno.land/x/view_engine/mod.ts";

// Initiate app
const app = new Application();
const router = new Router();

// Setting up boilerplate for view-engine
const ejsEngine = await engineFactory.getEjsEngine();
const oakAdapter = await adapterFactory.getOakAdapter();

// Passing view-engine as middleware
app.use(viewEngine(oakAdapter,ejsEngine));

// Adding middleware to require our router
app.use(router.routes());
app.use(router.allowedMethods());

// Creating Routes
router.get("/", (ctx) => {
    ctx.render('index.ejs', {data: {msg: "World"}})
})

// Making app to listen to port
console.log('App is listening to port: 8000');
await app.listen({port:8000});

以及index.ejs文件的示例

<html>
 <head>
  <title> Serving HTML</title> 
 </head>
 <body>
  <h1> Hello <%= data.msg %></h1> 
 </body>
</html>

有一个关于此的未决问题:https://github.com/denoland/deno/issues/6628

暂时在没有 --reload 的情况下尝试几次后,path 编译正确并且我能够正确 运行 脚本。

作为解决方法,您可以创建一个 test.ts 文件,在执行它之后,您将 path 下载并在缓存中正确编译。

import * as path from 'https://deno.land/std@0.59.0/path/mod.ts'

运行

deno run test.ts

然后

deno run --allow-net  main.ts