Deno: Cannot run testdata/006

Created on 1 Jun 2018  路  15Comments  路  Source: denoland/deno

Hi bro, I have configured the environment and run the deno, but I cannot pass the 6th test case, and the following is screenshot of terminal:
image

All 15 comments

It seems that this package is imported from a server. Since there is no server running at 4545 port on your local computer which serves the exact ts file, it might fail importing modules from that url.

@yuqingc Yeah, I also find this problem, but the error message is An import path cannot end with a '.ts', this isn't the real problem, is it?

The server is up already, because the tests are pass before 06, it seems like an issue about import on TypeScript.

FYI; you'll see this in case of lack of server:

Downloading http://localhost:4545/testdata/subdir/print_hello.ts
/main.js:15737
                throw _iteratorError;
                ^
TypeError: Cannot read property 'compileAndRun' of undefined
    at ../runtime.ts:132:19
    at Array.map (<anonymous>)
    at localDefine (../runtime.ts:120:23)
    at eval (/home/qti3e/go/src/deno/testdata/006_url_imports.ts, <anonymous>)
    at Object.eval [as globalEval] (<anonymous>)
    at execute (../runtime.ts:185:3)
    at FileModule.compileAndRun (../runtime.ts:93:5)
    at ../main.ts:50:9
    at ../dispatch.ts:68:5

@qti3e Yeah, if I run make test, all of tests are ok because the test.go will start a server. But when I use deno testdata/006_....., the error message isn't something about lacking of server, although I didn't start the server.

@yorkie The tests before 006 don't use importing by url, so they can pass

@monkingxue that's because Deno cache the files and doesn't send a network request.. (look at ~/.deno/src)

@monkingxue Can you provide the version of ts deno is using?

deno testdata/import_typescript.ts

@qti3e Absolutely right, typescript version 2.8.3.But I find the print_hello.ts file in .deno/cache rather than .deno/src

@mohsen1 So error is not related to TypeScript version as I have the same version...
btw, the file should be in ~/.deno/src/localhost:4545/testdata/subdir/print_hello.ts
if it's not maybe the issue is related to this?

@qti3e I have removed the cache file and src file, and just re-run the deno 006... but it still told me that An import path cannot end with a '.ts' extension

@qti3e

$ rm -rf ~/.deno/cache

$ rm -rf ~/.deno/src

$ deno testdata/006_url_imports.ts
Downloading http://localhost:4545/testdata/subdir/print_hello.ts
Downloading http://localhost:4545/testdata/subdir/print_hello.ts
Downloading http://localhost:4545/testdata/subdir/print_hello.ts
/Users/xueyingchen/Desktop/learn-one/go/src/github.com/ry/deno/testdata/006_url_imports.ts:1:28 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing 'http://localhost:4545/testdata/subdir/print_hello' instead.

1 import { printHello } from "http://localhost:4545/testdata/subdir/print_hello.ts";
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ ls ~/.deno/cache
<empty>
$ ls ~/.deno/src
<empty>

Ok! I've could reproduce the error :tada:
while you run make test Deno uses a diffrent cache dir:
https://github.com/ry/deno/blob/180f0a1b3cfa0f7cd1f37485839c763de4d03693/integration_test.go#L73-L86

so it can't use this cached file later when you want to execute code by your self : (
so you should do:

cd $GOPATH/src/github.com/deno
http-server -p 4545

and then try the code again (deno testdata/006/...), after that close your http-server
now you can try the code again and it should just work...

I'll close this issue as resolved : )

@qti3e, Yeah it's all right, but I think the error message should be lack of server when I didn't run the server port 4545.

@qti3e Reproduced this error and resolved this as you mentioned. thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

watilde picture watilde  路  3Comments

ry picture ry  路  3Comments

motss picture motss  路  3Comments

ry picture ry  路  3Comments

metakeule picture metakeule  路  3Comments