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

Incorrect relative module imports from remote scripts #645

Closed
NewLunarFire opened this issue Aug 31, 2018 · 5 comments
Closed

Incorrect relative module imports from remote scripts #645

NewLunarFire opened this issue Aug 31, 2018 · 5 comments
Labels
bug Something isn't working correctly
Milestone

Comments

@NewLunarFire
Copy link

The following

main.ts

import bar from "https://example.com/bar.ts"

bar.ts

import foo from "./foo.ts"

In the second example, foo.ts ends up resolving to "$HOME/.deno/deps/example.com/foo.ts" instead of the expected "https://example.com/foo.ts".

@ry ry added the bug Something isn't working correctly label Aug 31, 2018
@ry ry added this to the v0.2 milestone Aug 31, 2018
ry added a commit that referenced this issue Sep 5, 2018
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
ry added a commit that referenced this issue Sep 5, 2018
ry added a commit that referenced this issue Sep 5, 2018
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
Windows can't handle ":" in path names, so we use a special directory
format .deno/deps/localhost_PORT4545/ to represent hosts with
non-default ports.

Fixes denoland#645.
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
Windows can't handle ":" in path names, so we use a special directory
format .deno/deps/localhost_PORT4545/ to represent hosts with
non-default ports.

Fixes denoland#645.
ry added a commit to ry/deno that referenced this issue Sep 5, 2018
Windows can't handle ":" in path names, so we use a special directory
format .deno/deps/localhost_PORT4545/ to represent hosts with
non-default ports.

Fixes denoland#645.
@ry ry closed this as completed in e499080 Sep 6, 2018
ry added a commit to ry/deno that referenced this issue Sep 6, 2018
* Fixes module resolution error denoland#645
* Better flag parsing
* lStatSync -> lstatSync
* Added deno.renameSync()
* Added deno.mkdirSync()
* Fix circular dependencies denoland#653
* Added deno.env() and --allow-env
@ry ry mentioned this issue Sep 6, 2018
ry added a commit to ry/deno that referenced this issue Sep 6, 2018
* Fixes module resolution error denoland#645
* Better flag parsing
* lStatSync -> lstatSync
* Added deno.renameSync()
* Added deno.mkdirSync()
* Fix circular dependencies denoland#653
* Added deno.env() and --allow-env
ry added a commit that referenced this issue Sep 6, 2018
* Fixes module resolution error #645
* Better flag parsing
* lStatSync -> lstatSync
* Added deno.renameSync()
* Added deno.mkdirSync()
* Fix circular dependencies #653
* Added deno.env() and --allow-env
@DanielRamosAcosta
Copy link
Contributor

I might be having the same error at v0.1.3. I have this source file at Gist but my local module isn't able to import it:

myimport.ts:

import { factorial } from "https://gist.githubusercontent.com/DanielRamosAcosta/ad514503b1c7cf8290dadb96a5fddee9/raw/4733e267f05d20110ba962c4418bab5e98abfe93/factorial.ts"

console.log(factorial(10))

When executing I'm having the following error:

./deno myimport.ts
Error: Cannot resolve module "https://gist.githubusercontent.com/DanielRamosAcosta/ad514503b1c7cf8290dadb96a5fddee9/raw/4733e267f05d20110ba962c4418bab5e98abfe93/factorial.ts" from "/home/daniel/Documentos/Trabajo/deno-test/myimport.ts".
  Invalid source code or file name.
    at throwResolutionError (deno/js/compiler.ts:128:9)
    at DenoCompiler.resolveModule (deno/js/compiler.ts:526:14)
    at DenoCompiler.resolveModuleName (deno/js/compiler.ts:551:33)
    at moduleNames.map.name (deno/js/compiler.ts:679:33)
    at Array.map (<anonymous>)
    at DenoCompiler.resolveModuleNames (deno/js/compiler.ts:671:24)
    at Object.compilerHost.resolveModuleNames (deno/third_party/node_modules/typescript/lib/typescript.js:111649:117)
    at resolveModuleNamesWorker (deno/third_party/node_modules/typescript/lib/typescript.js:82561:106)
    at resolveModuleNamesReusingOldState (deno/third_party/node_modules/typescript/lib/typescript.js:82768:24)
    at processImportedModules (deno/third_party/node_modules/typescript/lib/typescript.js:84005:35)

Deno version:

deno: 0.1.3
v8: 7.0.247-deno

Any ideas?

@ry
Copy link
Member

ry commented Sep 7, 2018

@DanielRamosAcosta I was unable to repeat the error - it works for me.... I'm not sure what's happening

@johnsoncodehk
Copy link

@ry I am trying to run this example from https://deno.land/:

import { serve } from "https://deno.land/x/http/server.ts";
const s = serve("0.0.0.0:8000");

async function main() {
  for await (const req of s) {
    req.respond({ body: new TextEncoder().encode("Hello World\n") });
  }
}

main();

Then I got this error:

Uncaught NotFound: Cannot resolve module "../util/deferred.ts" from "/Users/johnsonchu/.deno/deps/https/deno.land/x/http/server.ts"

I guess you can reproduce this error after clearing the cache directory.

@hayd
Copy link
Contributor

hayd commented Feb 15, 2019

@johnsoncodehk Please try:

import { serve } from "https://deno.land/x/[email protected]/http/http.ts";

Edit: Actually this will work too:

import { serve } from "https://deno.land/x/std/http/server.ts";

but we should prefer and specifying the version in the url.

@johnsoncodehk
Copy link

@hayd Yes, it works, thank you!
And I found that the reason is that https://deno.land/x/util/deferred.ts failed to download.

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
Projects
None yet
Development

No branches or pull requests

5 participants