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>