The system cannot find the path specified. (os error 3)
Asked Answered
L

3

7

I am using deno for the first time and The system cannot find the path specified. (os error 3) is the error I am getting. My code below:-

import { Application } from 'https://deno.land/x/oak/mod.ts'

const app = new Application();
const port = 3000;

app.use((ctx) => {
    ctx.response.body = "Hello World"
})

app.listen({ port })
console.log(`localhost:${port}`)

I am using deno run --allow-net .\server.js on powershell to start deno. Any help would be appreciated.

EDIT: If I try to do a simple console.log and run the file with deno run server.js it runs fine which mean that the deno environment is setup correctly. As soon as I add the import statement at the top, the error starts happening.

Load answered 1/6, 2020 at 1:11 Comment(3)
Hm.. I tried it on my mac and it works just fine. What does deno --version give you?Frosted
it says 1.0.3Load
I have same error rust side. It is more than "C:/Users/<user>/<projectfolder>/src/main.rs" instead of "/src/main.rs" for windows.Culverin
C
1

The issue might be that you have a cached version of oak for an old version of deno.

do:

deno cache --reload server.js

And then run your server again:

deno run --allow-net server.js

It is considered a bad practice to use non-versioned URL, but in this case since there's no new version released yet for deno 1.0.3 you don't have a choice but to use master.


UPDATE: The error might be fixed by PR #6000

Coorg answered 1/6, 2020 at 11:16 Comment(0)
J
0

I got the same error. After some tries, I see that there is different betwwen nodejs and deno when use import. In node, we use this

import { Server } from './Server';

But in deno we use

import { Server } from './Server/index.js

It resolved my issue, hope is the same for you

Joanjoana answered 2/6, 2020 at 3:20 Comment(0)
M
0

I also got the same error. I did the following steps to resolve this error:

  1. If you have Visual Studio open, first close it.

  2. Open your command(cmd) prompt Run as Administrator

  3. Run this command scoop install deno

  4. Now open Visual Studio Code and Run Your Program using this command:

    deno run --allow-net --allow-read --allow-write ./server.js
    

    or

    deno run --allow-net --allow-read --allow-write .\server.js
    
Muzz answered 4/6, 2020 at 7:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.