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

Deno error pure js file #5982

Closed
js-writer opened this issue May 30, 2020 · 17 comments · Fixed by #6000 or #6177
Closed

Deno error pure js file #5982

js-writer opened this issue May 30, 2020 · 17 comments · Fixed by #6000 or #6177
Assignees
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@js-writer
Copy link

When I try to run deno.land server example code:

import { serve } from "https://deno.land/std@0.54.0/http/server.ts"; const s = serve({ port: 8000 }); console.log("http://localhost:8000/"); for await (const req of s) { req.respond({ body: "Hello World\n" }); }

but as JavaScript file (deno run --allow-net server.js) I get error:

[Error 3] The system cannot find the path specified

Only when I run it as .ts and then again as .js it work.

@SyrupThinker
Copy link
Contributor

Reproducible on Linux with Deno v1.0.3. The same example works with Deno v1.0.2.

This regressed with ad6d2a7 (determined with git bisect).

@js-writer
Copy link
Author

I forget to mention I am on windows 10, deno v1.0.3

@bartlomieju bartlomieju self-assigned this May 31, 2020
@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels May 31, 2020
@sandeepgokhale
Copy link

I had the same problem a few minutes again, .ts would work, but not .js.

However, looks like even the .js works now.. Someone fixed already ?

deno run --allow-net helloWorld.ts
or
deno run --allow-net helloWorld.js

both works.

Thanks much & stay safe !

@bartlomieju
Copy link
Member

This error is caused by the fact that pre 1.0.3 TS compiler was created on demand for each encountered .ts import - even when such import occurred in .js file. In 1.0.3 compilation is can only be performed upfront and this case wasn't covered.

Question is: is importing .ts file from .js file a valid import? If so, fixing this problem should be rather easy by spinning TS compiler if any of the dependencies in module graph is a TS file (in addition to current logic that uses checkJs compiler setting to type check .js files).

@kitsonk @ry WDYT?

@nayeemrmn
Copy link
Collaborator

Question is: is importing .ts file from .js file a valid import?

Incrementally converting a project from JS to TS would be tough if not. I think unsafe code should be able to call safe code.

@bartlomieju
Copy link
Member

Question is: is importing .ts file from .js file a valid import?

Incrementally converting a project from JS to TS would be tough if not. I think unsafe code should be able to call safe code.

Yeah, good argument.

@js-writer
Copy link
Author

@sandeepgokhale If you add new import (that you never have before) to your helloWorld.js and try to run it then you should get error.

When you compile .ts and then .js everything is working. Problem is when you do some new stuff on .js without .ts compilation. (At least that's my guessing)

@kitchanismo
Copy link

can i go back to previous version to fix this issue?

@lucacasonato
Copy link
Member

This error should be fixed in the latest release (1.0.4)

@kitchanismo
Copy link

when i use denodb package, i still encounter this error,
The system cannot find the path specified. (os error 3)

@js-writer
Copy link
Author

@lucacasonato Unfortunately it is not.
I check it on two PC with windows 10.
Now when I run helloWorld.js I have this error:
error: Uncaught AssertionError: Unexpected skip of the emit. at Object.assert ($deno$/util.ts:33:11) at compile ($deno$/compiler.ts:1170:7) at tsCompilerOnMessage ($deno$/compiler.ts:1338:22) at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)

@nayeemrmn
Copy link
Collaborator

nayeemrmn commented Jun 3, 2020

Yes, still an issue on 1.0.5. Repro:
temp.js:

import "https://deno.land/std@0.56.0/examples/welcome.ts";
Download https://deno.land/std@0.56.0/examples/welcome.ts
Compile file:///mnt/c/Users/Nayeem/projects/deno/temp.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///mnt/c/Users/Nayeem/projects/deno/__anonymous__:1:1

If I import a local TS file instead of that remote one, the error won't occur.


And any module that depends on temp.js will instead throw the original error:
temp2.js:

import "./temp.js";
Download https://deno.land/std@0.56.0/examples/welcome.ts
Compile file:///mnt/c/Users/Nayeem/projects/deno/temp2.js
error: No such file or directory (os error 2)

Same result if I used TS here.

@imaginamundo
Copy link

imaginamundo commented Jun 3, 2020

I am running into this issue today, some details bellow:

On MacOS 10.5.4, here are my files:

deps.js

export { Application } from "https://deno.land/x/oak@v5.0.0/mod.ts";

mod.js

import { Application } from "./deps.js";

const app = new Application();

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

await app.listen({ port: 8000 });

Running with the command:

deno run --allow-net mod.js

Console error:

Compile file:///Users/dio/dev/test/mod.js
error: No such file or directory (os error 2)

My current Deno setup:

deno: 1.0.5
v8: 8.4.300
typescript: 3.9.2

Happening since I've start testing a deps file on Deno 1.0.4

Edit:
If I try to change the deps.js file to deps.ts, the error changes to:

Compile file:///Users/dio/dev/test/mod.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///Users/dio/dev/test/__anonymous__:1:1

@lemaguilera
Copy link

I have exactly the same error from today that I went from version 1.0.3 to 1.0.5

@bartlomieju
Copy link
Member

Update: I'm looking into this issue and found root cause. Fix will be released in Deno 1.1 in a few days.

@pauldavid23
Copy link

I also have this issue. How to fix it?

@bartlomieju
Copy link
Member

The fix was released in Deno v1.1.0. Please upgrade and let us know if problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet