Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ralyodio opened this issue Oct 5, 2021 · 3 comments
Open

Comments

@ralyodio
Copy link

ralyodio commented Oct 5, 2021

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

@irustm
Copy link
Member

irustm commented Oct 5, 2021

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
Copy link
Member

irustm commented Oct 15, 2021

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

@yogiswar1987
Copy link

yogiswar1987 commented Dec 14, 2022

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/oak@v11.1.0/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/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants