0

After running my main.ts file with deno I get this error:

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)

I am running my file with this command: deno run --allow-net main.ts and I also tried deno run --allow-net --allow-read main.ts but same error occurs.

My main.ts file:

// 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});

And an example of index.ejs file

<html>
 <head>
  <title> Serving HTML</title> 
 </head>
 <body>
  <h1> Hello <%= data.msg %></h1> 
 </body>
</html>
Gabriel Arghire
  • 1,992
  • 1
  • 21
  • 34
  • If I run ```deno cache --reload main.ts``` I also get the same error. I also tried answers from [here](https://stackoverflow.com/q/62124334/11322237) but no success. – Gabriel Arghire Jul 07 '20 at 20:28

1 Answers1

1

There's an open issue regarding this: https://github.com/denoland/deno/issues/6628

For the time being after trying a couple of times without --reload, path was compiled correctly and I was able to run the script correctly.

As a workaround, you can create a test.ts file and after you execute it, you'll have path downloaded and compiled correctly in the cache.

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

Run

deno run test.ts

and then

deno run --allow-net  main.ts
Marcos Casagrande
  • 37,983
  • 8
  • 84
  • 98
  • Even with that issue apparently fixed, I still get it on my Mac: Warning Failed to get compiled source code of "https://deno.land/x/denjucks@1.1.1/src/deps/path/std/path/mod.ts". Reason: No such file or directory (os error 2) – Chris Aug 07 '20 at 13:54