The system cannot find the path specified. (os error 3) - deno

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.

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

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

I also got the same error. I did the following steps to resolve this error:
If you have Visual Studio open, first close it.
Open your command(cmd) prompt Run as Administrator
Run this command scoop install deno
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

Related

Unable to run deno task start with invalid source code error

I have a deno repository of my own. I have recently switched to a new machine, and I have git clone'd that repository to my new machine.
Now when I run deno task start, it fails with this error
❯ deno task start
Task start deno run -A --watch=static/,routes/ dev.ts
Watcher Process started.
The manifest has been generated for 3 routes and 2 islands.
error: The source code is invalid, as it does not match the expected hash in the lock file.
Specifier: https://esm.sh/*preact-render-to-string#5.2.4
Lock file: /Users/john/my-project/deno.lock
I have read this page, but it is not telling me exactly what to do for my error
https://deno.land/manual#v1.29.4/basics/modules/integrity_checking
Based off of what that page says, the contents of one of your dependencies has changed since your original computer downloaded it for the first time, so the hash of the contents are different.
If you just want to ignore this, it says to use the flags
--lock=deno.lock --lock-write
which I assume means to run
deno task start --lock=deno.lock --lock-write
This will overwrite the current lock file with the new version of the code.
While this will work, the better option for the future is to specify the version in your dependency url.
For example, instead of
import { z } from "https://deno.land/x/zod/mod.ts";
you should say
import { z } from "https://deno.land/x/zod#v3.20.2/mod.ts";
(the #v3.20.2 specfies the exact dependency version)

Deno 500 error from dev.jspm.io installing dependencies

I'm trying to run my first deno script which is pretty much from the denoDB docs, it just tries to connect to a database with a SQLite3 connector (I'm on a Macbook pro so it should be installed):
import { Database, SQLite3Connector } from 'https://deno.land/x/denodb/mod.ts';
const connector = new SQLite3Connector({
filepath: './db.sqlite',
});
export const db = new Database(connector);
I'm running deno run api/db.ts and I get this error after a few successful downloads:
Download https://deno.land/std#0.149.0/encoding/hex.ts
Download https://deno.land/std#0.149.0/hash/_wasm/lib/deno_hash.generated.mjs
error: Import 'https://dev.jspm.io/inherits#2.0' failed: 500 Internal Server Error
at https://raw.githubusercontent.com/Zhomart/dex/930253915093e1e08d48ec0409b4aee800d8bd0c/lib-dyn/deps.ts:4:26
I've deleted my /Users/<me>/Library/Caches/deno/deps/https and reran the script a few times but I still can't get past this. In my browser trying to follow the URL https://dev.jspm.io/inherits#2.0 does give me an error. What is going on here? There's not much code and I imagine it's not broken for everybody. What do I need to do to get this script to run without issues?
EDIT: it seems to be a library error https://github.com/eveningkid/denodb/issues/348
This is an error caused by a nested depedency, from a project that is not maintained.
See this for more info: [https://jspm.org/jspm-dev-release]
The point is dev.jspm.io is now jspm.dev
A way to fix this is to fork and update depedencies.
Another thing, if you're not using deno deploy, you can just use this as a replacement for your denodb: https://raw.githubusercontent.com/joeldesante/denodb/master/mod.ts
Just note that this script is no more maintained either, but it will fix your problem
Edit
I just made a dirty quick fix for deno deploy use this as a depedency isntead of denodb: https://raw.githubusercontent.com/ninjinskii/denodb/master/mod.ts
Again, i may not maintain this script forever.
The best thing that can happen is an update from these libs maintainers

Deno Uncaught SyntaxError: Unexpected identifier at evaluate ($deno$/repl.ts:54:34) at Object.replLoop ($deno$/repl.ts:156:13)

I installed Deno using this choco install deno command, if I typed deno, I got the version, but if I try to run my index file, I got this error and whatever I typed i got the error like this(refer the image), what went wrong here, thank you
Uncaught SyntaxError: Unexpected identifier
at evaluate ($deno$/repl.ts:54:34)
at Object.replLoop ($deno$/repl.ts:156:13)
My index file
import {Application} from 'https://deno.land/x/oak/mod.ts';
import {PORT} from './config.js';
import router from '.router.js';
const app=new Application();
app.use(router.routes());
app.use(router.allwedMethods());
console.log('Server is running. Open http://localhost:${PORT}');
await app.listen({port:PORT});
config.js
export const PORT=5000;
router.js
import {Router} from 'https://deno.land/x/oak/mod.ts';
const router=new Router();
router.get('/',({response})=>{
response.body='Working';
});
export default router;
Can you try run the same RPL command with --ts flag like:
deno run --allow-net --ts and all other flag you use
I installed version 1.0.3 so that I got the error, After that, I uploaded to 1.0.0 or 1.0.5, I never get this warning
To solve this problem,
Open the Command prompt to click Run as Administrator, After that
Run this Command to scoop install deno#1.0.0
Run The program again and Chech it.
# Install a specific version of deno:
scoop install deno#1.0.0
# Switch to v1.0.0
scoop reset deno#1.0.0
# Switch to the latest version
scoop reset deno

drun is showing me error "not yet implemented"

I am starting my Deno Server using drun Automatically restart server
drun --entryPoint=./index.ts
The server started at first run successfull but when i make any changes in deno code and save it the result is as below
Compile file:///C:/Users/rajat/Desktop/demo/index.ts
Serving on http://0.0.0.0:3000/
Error: Not yet implemented
at Object.kill ($deno$/ops/process.ts:8:11)
at Process.kill ($deno$/process.ts:89:5)
at Runner.run (https://deno.land/x/drun#v1.0.0/src/runner.ts:69:17)
at async main (https://deno.land/x/drun#v1.0.0/drun.ts:11:3)
at async https://deno.land/x/drun#v1.0.0/drun.ts:16:5
process.kill is not implemented on Windows on your Deno version. A PR to support it was merged 4 days ago
Upgrade your Deno version to 1.0.1 which includes:
fix: Implement Deno.kill for windows (#5347)

karate chrome(chromium-browser) driver configuration

I need to launch a url for UI testing in a KarateDSL scenario.
I have configured, in Feature -> Background:
* configure driver = { type: 'chrome', executable: 'chromesh' }
Where, chromesh is a executable (chromium-browser launching) bash script in ~/.local/bin.
At run it always seems to be using the default driver config:
18:38:09.781 [null_1552396089768] ERROR c.intuit.karate.shell.CommandThread - command error: [/Applications/Google Chrome.app/Contents/MacOS/Google Chrome, --remote-debugging-port=9222, --no-first-run, --user-data-dir=/home/../target/null_1552396089768, --headless] - Cannot run program "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" (in directory "target/null_1552396089768"): error=2, No such file or directory
Karate version: 0.9.1
Is there any configuration I'm missing or done wrong?
Thanks.
Are you using IntelliJ - there's this known problem where it does not honor the system environmental variables in some situations.
Try running your test from the command line via maven, e.g.
mvn test -Dtest=MyJunitRunner

Resources