Deno Install on Standard Library File Server TypeScript Error
Describe the bug When I attempt to installed the Deno standard library file server, I get type errors.
Steps to Reproduce
- In my project's root directory, I ran the install command, as per the instructions in the manual (https://deno.land/manual/examples/file_server).
deno install --allow-net --allow-read https://deno.land/[email protected]/http/file_server.ts
$ (deno install --allow-net --allow-read https://deno.land/[email protected]/http/file_server.ts) > ~/file_server_error.txt
Check https://deno.land/[email protected]/http/file_server.ts
error: TS2339 [ERROR]: Property 'reason' does not exist on type 'AbortSignal'.
return Promise.reject(createAbortError(signal.reason));
at https://deno.land/[email protected]/async/abortable.ts:27:51
TS2339 [ERROR]: Property 'reason' does not exist on type 'AbortSignal'.
const abort = () => waiter.reject(createAbortError(signal.reason));
at https://deno.land/[email protected]/async/abortable.ts:30:61
TS2339 [ERROR]: Property 'reason' does not exist on type 'AbortSignal'.
throw createAbortError(signal.reason);
at https://deno.land/[email protected]/async/abortable.ts:46:35
TS2339 [ERROR]: Property 'reason' does not exist on type 'AbortSignal'.
const abort = () => waiter.reject(createAbortError(signal.reason));
at https://deno.land/[email protected]/async/abortable.ts:49:61
TS2503 [ERROR]: Cannot find namespace 'Deno'.
readonly localAddr: Deno.Addr;
at https://deno.land/[email protected]/http/server.ts:22:23
TS2503 [ERROR]: Cannot find namespace 'Deno'.
readonly remoteAddr: Deno.Addr;
at https://deno.land/[email protected]/http/server.ts:24:24
TS2503 [ERROR]: Cannot find namespace 'Deno'.
export interface ServerInit extends Partial<Deno.ListenOptions> {
at https://deno.land/[email protected]/http/server.ts:41:45
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#listeners: Set<Deno.Listener> = new Set();
at https://deno.land/[email protected]/http/server.ts:59:19
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#httpConnections: Set<Deno.HttpConn> = new Set();
at https://deno.land/[email protected]/http/server.ts:60:25
TS2339 [ERROR]: Property 'port' does not exist on type 'ServerInit'.
this.#port = serverInit.port;
at https://deno.land/[email protected]/http/server.ts:84:29
TS2339 [ERROR]: Property 'hostname' does not exist on type 'ServerInit'.
this.#host = serverInit.hostname;
at https://deno.land/[email protected]/http/server.ts:85:29
TS2503 [ERROR]: Cannot find namespace 'Deno'.
async serve(listener: Deno.Listener): Promise<void> {
at https://deno.land/[email protected]/http/server.ts:126:25
TS2304 [ERROR]: Cannot find name 'Deno'.
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
at https://deno.land/[email protected]/http/server.ts:128:17
TS2304 [ERROR]: Cannot find name 'Deno'.
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
at https://deno.land/[email protected]/http/server.ts:178:17
TS2304 [ERROR]: Cannot find name 'Deno'.
const listener = Deno.listen({
at https://deno.land/[email protected]/http/server.ts:181:22
TS2304 [ERROR]: Cannot find name 'Deno'.
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
at https://deno.land/[email protected]/http/server.ts:228:17
TS2304 [ERROR]: Cannot find name 'Deno'.
const listener = Deno.listenTls({
at https://deno.land/[email protected]/http/server.ts:231:22
TS2304 [ERROR]: Cannot find name 'Deno'.
throw new Deno.errors.Http(ERROR_SERVER_CLOSED);
at https://deno.land/[email protected]/http/server.ts:251:17
TS2503 [ERROR]: Cannot find namespace 'Deno'.
get addrs(): Deno.Addr[] {
at https://deno.land/[email protected]/http/server.ts:279:16
TS2503 [ERROR]: Cannot find namespace 'Deno'.
requestEvent: Deno.RequestEvent,
at https://deno.land/[email protected]/http/server.ts:291:19
TS2503 [ERROR]: Cannot find namespace 'Deno'.
httpConn: Deno.HttpConn,
at https://deno.land/[email protected]/http/server.ts:292:15
TS2503 [ERROR]: Cannot find namespace 'Deno'.
async #serveHttp(httpConn: Deno.HttpConn, connInfo: ConnInfo): Promise<void> {
at https://deno.land/[email protected]/http/server.ts:321:30
TS2503 [ERROR]: Cannot find namespace 'Deno'.
let requestEvent: Deno.RequestEvent | null;
at https://deno.land/[email protected]/http/server.ts:323:25
TS2503 [ERROR]: Cannot find namespace 'Deno'.
async #accept(listener: Deno.Listener): Promise<void> {
at https://deno.land/[email protected]/http/server.ts:351:27
TS2503 [ERROR]: Cannot find namespace 'Deno'.
let conn: Deno.Conn;
at https://deno.land/[email protected]/http/server.ts:355:17
TS2304 [ERROR]: Cannot find name 'Deno'.
error instanceof Deno.errors.BadResource ||
at https://deno.land/[email protected]/http/server.ts:363:28
TS2304 [ERROR]: Cannot find name 'Deno'.
error instanceof Deno.errors.InvalidData ||
at https://deno.land/[email protected]/http/server.ts:365:28
TS2304 [ERROR]: Cannot find name 'Deno'.
error instanceof Deno.errors.UnexpectedEof ||
at https://deno.land/[email protected]/http/server.ts:366:28
TS2304 [ERROR]: Cannot find name 'Deno'.
error instanceof Deno.errors.ConnectionReset ||
at https://deno.land/[email protected]/http/server.ts:367:28
TS2304 [ERROR]: Cannot find name 'Deno'.
error instanceof Deno.errors.NotConnected
at https://deno.land/[email protected]/http/server.ts:368:28
TS2503 [ERROR]: Cannot find namespace 'Deno'.
let httpConn: Deno.HttpConn;
at https://deno.land/[email protected]/http/server.ts:394:21
TS2304 [ERROR]: Cannot find name 'Deno'.
httpConn = Deno.serveHttp(conn);
at https://deno.land/[email protected]/http/server.ts:397:20
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#closeHttpConn(httpConn: Deno.HttpConn): void {
at https://deno.land/[email protected]/http/server.ts:424:28
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#trackListener(listener: Deno.Listener): void {
at https://deno.land/[email protected]/http/server.ts:439:28
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#untrackListener(listener: Deno.Listener): void {
at https://deno.land/[email protected]/http/server.ts:448:30
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#trackHttpConnection(httpConn: Deno.HttpConn): void {
at https://deno.land/[email protected]/http/server.ts:457:34
TS2503 [ERROR]: Cannot find namespace 'Deno'.
#untrackHttpConnection(httpConn: Deno.HttpConn): void {
at https://deno.land/[email protected]/http/server.ts:466:36
TS2503 [ERROR]: Cannot find namespace 'Deno'.
export interface ServeInit extends Partial<Deno.ListenOptions> {
at https://deno.land/[email protected]/http/server.ts:472:44
TS2503 [ERROR]: Cannot find namespace 'Deno'.
listener: Deno.Listener,
at https://deno.land/[email protected]/http/server.ts:505:13
TS2345 [ERROR]: Argument of type '{ port: any; hostname: any; handler: Handler; onError: ((error: unknown) => Response | Promise<Response>) | undefined; }' is not assignable to parameter of type 'ServerInit'.
Object literal may only specify known properties, and 'port' does not exist in type 'ServerInit'.
port: options.port ?? 8000,
at https://deno.land/[email protected]/http/server.ts:547:5
TS2339 [ERROR]: Property 'port' does not exist on type 'ServeInit'.
port: options.port ?? 8000,
at https://deno.land/[email protected]/http/server.ts:547:19
TS2339 [ERROR]: Property 'hostname' does not exist on type 'ServeInit'.
hostname: options.hostname ?? "0.0.0.0",
at https://deno.land/[email protected]/http/server.ts:548:23
TS2345 [ERROR]: Argument of type '{ port: any; hostname: any; handler: Handler; onError: ((error: unknown) => Response | Promise<Response>) | undefined; }' is not assignable to parameter of type 'ServerInit'.
Object literal may only specify known properties, and 'port' does not exist in type 'ServerInit'.
port: options.port ?? 8443,
at https://deno.land/[email protected]/http/server.ts:602:5
TS2339 [ERROR]: Property 'port' does not exist on type 'ServeTlsInit'.
port: options.port ?? 8443,
at https://deno.land/[email protected]/http/server.ts:602:19
TS2339 [ERROR]: Property 'hostname' does not exist on type 'ServeTlsInit'.
hostname: options.hostname ?? "0.0.0.0",
at https://deno.land/[email protected]/http/server.ts:603:23
TS2503 [ERROR]: Cannot find namespace 'Deno'.
config: Partial<Deno.ListenOptions>,
at https://deno.land/[email protected]/http/server.ts:648:19
TS2503 [ERROR]: Cannot find namespace 'Deno'.
config: Partial<Deno.ListenOptions>,
at https://deno.land/[email protected]/http/server.ts:698:19
TS2503 [ERROR]: Cannot find namespace 'Deno'.
fileInfo?: Deno.FileInfo;
at https://deno.land/[email protected]/http/file_server.ts:252:14
TS2503 [ERROR]: Cannot find namespace 'Deno'.
let file: Deno.FsFile;
at https://deno.land/[email protected]/http/file_server.ts:268:13
TS2304 [ERROR]: Cannot find name 'Deno'.
Deno.open(filePath),
at https://deno.land/[email protected]/http/file_server.ts:271:7
TS2304 [ERROR]: Cannot find name 'Deno'.
Deno.stat(filePath),
at https://deno.land/[email protected]/http/file_server.ts:272:7
TS2304 [ERROR]: Cannot find name 'Deno'.
file = await Deno.open(filePath);
at https://deno.land/[email protected]/http/file_server.ts:275:18
TS2304 [ERROR]: Cannot find name 'Deno'.
await file.seek(start, Deno.SeekMode.Start);
at https://deno.land/[email protected]/http/file_server.ts:373:34
TS2304 [ERROR]: Cannot find name 'Deno'.
const fileInfo = await Deno.stat(prevPath);
at https://deno.land/[email protected]/http/file_server.ts:426:28
TS2304 [ERROR]: Cannot find name 'Deno'.
for await (const entry of Deno.readDir(dirPath)) {
at https://deno.land/[email protected]/http/file_server.ts:435:29
TS2304 [ERROR]: Cannot find name 'Deno'.
const fileInfo = await Deno.stat(filePath);
at https://deno.land/[email protected]/http/file_server.ts:441:28
TS2304 [ERROR]: Cannot find name 'Deno'.
} else if (e instanceof Deno.errors.NotFound) {
at https://deno.land/[email protected]/http/file_server.ts:475:27
TS2304 [ERROR]: Cannot find name 'Deno'.
throw new Deno.errors.NotFound();
at https://deno.land/[email protected]/http/file_server.ts:688:19
TS2304 [ERROR]: Cannot find name 'Deno'.
const fileInfo = await Deno.stat(fsPath);
at https://deno.land/[email protected]/http/file_server.ts:693:28
TS2304 [ERROR]: Cannot find name 'Deno'.
throw new Deno.errors.NotFound();
at https://deno.land/[email protected]/http/file_server.ts:702:19
TS2304 [ERROR]: Cannot find name 'Deno'.
const serverArgs = parse(Deno.args, {
at https://deno.land/[email protected]/http/file_server.ts:765:28
TS2304 [ERROR]: Cannot find name 'Deno'.
Deno.exit();
at https://deno.land/[email protected]/http/file_server.ts:793:5
TS2304 [ERROR]: Cannot find name 'Deno'.
Deno.exit(1);
at https://deno.land/[email protected]/http/file_server.ts:800:7
TS2345 [ERROR]: Argument of type '{ port: number; hostname: any; certFile: any; keyFile: any; }' is not assignable to parameter of type 'ServeTlsInit'.
Object literal may only specify known properties, and 'port' does not exist in type 'ServeTlsInit'.
port: Number(port),
at https://deno.land/[email protected]/http/file_server.ts:821:7
TS2345 [ERROR]: Argument of type '{ port: number; hostname: any; }' is not assignable to parameter of type 'ServeInit'.
Object literal may only specify known properties, and 'port' does not exist in type 'ServeInit'.
serve(handler, { port: Number(port), hostname: host });
at https://deno.land/[email protected]/http/file_server.ts:827:22
TS2339 [ERROR]: Property 'main' does not exist on type 'ImportMeta'.
if (import.meta.main) {
at https://deno.land/[email protected]/http/file_server.ts:865:17
Found 66 errors.
- But when I try the same command from my home directory (
~/), the install works fine. Could this be because I have adeno.jsonfile in my project directory? I read about that file name somewhere but I've never found any evidence that it's actually used without me passing it to the--configparameter.
Expected behavior
I enter the command in my project directory, and file_server is installed.
$ deno install --allow-net --allow-read https://deno.land/[email protected]/http/file_server.ts
Check https://deno.land/[email protected]/http/file_server.ts
✅ Successfully installed file_server
/home/user/snap/deno/73/.deno/bin/file_server
ℹ️ Add /home/user/snap/deno/73/.deno/bin to PATH
export PATH="/home/user/snap/deno/73/.deno/bin:$PATH"
Environment
- OS: Pop!_OS 21.10 (x86_64-unknown-linux-gnu)
- deno version: 1.21.0
- std version: 0.136.0
3. Could this be because I have a
deno.jsonfile in my project directory? I read about that file name somewhere but I've never found any evidence that it's actually used without me passing it to the--configparameter.
You most likely have type libs set in deno.json which are meant for maybe a front end. Yes, deno.json is detected automatically as of 1.18 https://deno.com/blog/v1.18#auto-discovery-of-the-config-file.
Yep, that would be the issue; in the future I'll run the install command from a directory that doesn't have deno.json.