handlebars icon indicating copy to clipboard operation
handlebars copied to clipboard

[uncaught oak error]: NotFound - No such file or directory (os error 2)

Open ralyodio opened this issue 4 years ago • 3 comments

is this not correct layout?

$ find . -type f
./views/index.hbs
./views/layouts/main.hbs
./index.ts
import { Application, Router, Status } from 'https://deno.land/x/oak/mod.ts'
import { Handlebars } from 'https://deno.land/x/handlebars/mod.ts'

const port = 8080

const app = new Application()
const router = new Router()
const handle = new Handlebars()

// the routes defined here
router.get('/', async context => {
    const data = {
			title: 'Fools Day',
			date: '01/04/20'
		}
    context.response.body = await handle.renderView('index', data)
})

app.use(router.routes())
app.use(router.allowedMethods())

// static content
app.use(async (context, next) => {
    const root = `${Deno.cwd()}/static`
    try {
        await context.send({ root })
    } catch {
        next()
    }
})

app.addEventListener("listen", ({ port }) => console.log(`listening on port: ${port}`) )

await app.listen({ port })

ralyodio avatar Oct 05 '21 09:10 ralyodio

What operating system are you using? What version of Deno?

Please check what this code will output in your environment:

import { Application, Router, Status } from 'https://deno.land/x/oak/mod.ts'
import { Handlebars } from 'https://deno.land/x/handlebars/mod.ts'

const handle = new Handlebars();
console.log(await handle.renderView('index', {}));

that way you can catch the error, whose side it is on

irustm avatar Oct 05 '21 11:10 irustm

I updated the Deno dependencies, I think it should work now

irustm avatar Oct 15 '21 17:10 irustm

Below is reponse for your code Using MAC Monterey 12.6 Deno 1.28.3 IN-MAC-163:ott yreddivari$ deno run --allow-read index.ts Download ⠇ https://deno.land/x/oak/mod.ts Warning Implicitly using latest version (v11.1.0) for https://deno.land/x/oak/mod.ts Download ⠋ https://deno.land/x/[email protected]/mod.ts Warning Implicitly using latest version (v0.9.0) for https://deno.land/x/handlebars/mod.ts error: Uncaught Error: No such file or directory (os error 2), readdir 'views/partials/' for path "views/partials/"

yogiswar1987 avatar Dec 14 '22 06:12 yogiswar1987