esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

Failed to import - readdirp

Open chmac opened this issue 3 years ago • 2 comments

Failing module

  • GitHub: https://github.com/paulmillr/readdirp
  • npm: https://www.npmjs.com/package/readdirp
xport { default as readdirp } from "https://esm.sh/[email protected]";

Error message

After running deno run I got this:

$ deno cache --lock=lock.json --lock-write deps.ts
Check file:///.../deps.ts
error: TS2300 [ERROR]: Duplicate identifier 'URLSearchParams'.
declare class URLSearchParams {
              ~~~~~~~~~~~~~~~
    at asset:///lib.deno.url.d.ts:8:15

    'URLSearchParams' was also declared here.
            interface URLSearchParams extends _URLSearchParams {}
                      ~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v69/@types/node/url.d.ts:822:19    and here.
            var URLSearchParams:
                ~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v69/@types/node/url.d.ts:843:13

TS2300 [ERROR]: Duplicate identifier 'URL'.
declare class URL {
              ~~~
    at asset:///lib.deno.url.d.ts:155:15

    'URL' was also declared here.
            interface URL extends _URL {}
                      ~~~
        at https://cdn.esm.sh/v69/@types/node/url.d.ts:823:19    and here.
            var URL:
                ~~~
        at https://cdn.esm.sh/v69/@types/node/url.d.ts:833:13

TS2339 [ERROR]: Property 'getUid' does not exist on type 'typeof Deno'.
    if (Deno.build.os !== "windows" && info.uid === Deno.getUid()) {
                                                         ~~~~~~
    at https://deno.land/[email protected]/node/_fs/_fs_access.ts:24:58

TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
     ~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v69/node.ns.d.ts:7:6

    'BufferEncoding' was also declared here.
            type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
                 ~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:171:14

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
type WithImplicitCoercion<T> = T | { valueOf(): T };
     ~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v69/node.ns.d.ts:9:6

    'WithImplicitCoercion' was also declared here.
            type WithImplicitCoercion<T> =
                 ~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:172:14

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
declare class Buffer extends Uint8Array {
              ~~~~~~
    at https://cdn.esm.sh/v69/node.ns.d.ts:16:15

    'Buffer' was also declared here.
            interface Buffer extends Uint8Array {
                      ~~~~~~
        at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:532:19    and here.
            var Buffer: BufferConstructor;
                ~~~~~~
        at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:2196:13

TS2300 [ERROR]: Duplicate identifier 'internal'.
    export = internal;
             ~~~~~~~~
    at https://cdn.esm.sh/v69/@types/node/stream.d.ts:1245:14

    'internal' was also declared here.
        export = internal;
                 ~~~~~~~~
        at https://cdn.esm.sh/v66/@types/node/stream.d.ts:1245:14

TS2300 [ERROR]: Duplicate identifier 'stream'.
    export = stream;
             ~~~~~~
    at https://cdn.esm.sh/v69/@types/node/stream.d.ts:1249:14

    'stream' was also declared here.
        export = stream;
                 ~~~~~~
        at https://cdn.esm.sh/v66/@types/node/stream.d.ts:1249:14

TS2661 [ERROR]: Cannot export 'Buffer'. Only local declarations can be exported from a module.
    export { Buffer };
             ~~~~~~
    at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:98:14

TS2300 [ERROR]: Duplicate identifier 'BufferEncoding'.
        type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
             ~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:171:14

    'BufferEncoding' was also declared here.
    type BufferEncoding = "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex";
         ~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v69/node.ns.d.ts:7:6

TS2300 [ERROR]: Duplicate identifier 'WithImplicitCoercion'.
        type WithImplicitCoercion<T> =
             ~~~~~~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:172:14

    'WithImplicitCoercion' was also declared here.
    type WithImplicitCoercion<T> = T | { valueOf(): T };
         ~~~~~~~~~~~~~~~~~~~~
        at https://cdn.esm.sh/v69/node.ns.d.ts:9:6

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
        interface Buffer extends Uint8Array {
                  ~~~~~~
    at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:532:19

    'Buffer' was also declared here.
    declare class Buffer extends Uint8Array {
                  ~~~~~~
        at https://cdn.esm.sh/v69/node.ns.d.ts:16:15

TS2300 [ERROR]: Duplicate identifier 'Buffer'.
        var Buffer: BufferConstructor;
            ~~~~~~
    at https://cdn.esm.sh/v69/@types/node/buffer.d.ts:2196:13

    'Buffer' was also declared here.
    declare class Buffer extends Uint8Array {
                  ~~~~~~
        at https://cdn.esm.sh/v69/node.ns.d.ts:16:15

TS2300 [ERROR]: Duplicate identifier 'URLSearchParams'.
        interface URLSearchParams extends _URLSearchParams {}
                  ~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v69/@types/node/url.d.ts:822:19

    'URLSearchParams' was also declared here.
    declare class URLSearchParams {
                  ~~~~~~~~~~~~~~~
        at asset:///lib.deno.url.d.ts:8:15

TS2300 [ERROR]: Duplicate identifier 'URL'.
        interface URL extends _URL {}
                  ~~~
    at https://cdn.esm.sh/v69/@types/node/url.d.ts:823:19

    'URL' was also declared here.
    declare class URL {
                  ~~~
        at asset:///lib.deno.url.d.ts:155:15

TS2300 [ERROR]: Duplicate identifier 'URL'.
        var URL:
            ~~~
    at https://cdn.esm.sh/v69/@types/node/url.d.ts:833:13

    'URL' was also declared here.
    declare class URL {
                  ~~~
        at asset:///lib.deno.url.d.ts:155:15

TS2300 [ERROR]: Duplicate identifier 'URLSearchParams'.
        var URLSearchParams:
            ~~~~~~~~~~~~~~~
    at https://cdn.esm.sh/v69/@types/node/url.d.ts:843:13

    'URLSearchParams' was also declared here.
    declare class URLSearchParams {
                  ~~~~~~~~~~~~~~~
        at asset:///lib.deno.url.d.ts:8:15

TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: Type, promises, PathLike, PathOrFileDescriptor, TimeLike, NoParamCallback, BufferEncodingOption, EncodingOption, OpenMode, Mode, Stats, Dirent, Dir, ReadStream, WriteStream, statSync, lstatSync, ReadPosition, WriteFileOptions, WatchEventType, WatchListener, F_OK, R_OK, W_OK, X_OK, COPYFILE_EXCL, COPYFILE_FICLONE, COPYFILE_FICLONE_FORCE, O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_DIRECTORY, O_NOATIME, O_NOFOLLOW, O_SYNC, O_DSYNC, O_SYMLINK, O_DIRECT, O_NONBLOCK, S_IFMT, S_IFREG, S_IFDIR, S_IFCHR, S_IFBLK, S_IFIFO, S_IFLNK, S_IFSOCK, S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP, S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH, UV_FS_O_FILEMAP
declare module 'fs' {
~~~~~~~
    at https://cdn.esm.sh/v69/@types/node/fs.d.ts:22:1

    Conflicts are in this file.
    declare module 'fs' {
    ~~~~~~~
        at https://cdn.esm.sh/v66/@types/node/fs.d.ts:22:1

TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: Type, promises, PathLike, PathOrFileDescriptor, TimeLike, NoParamCallback, BufferEncodingOption, EncodingOption, OpenMode, Mode, Stats, Dirent, Dir, ReadStream, WriteStream, statSync, lstatSync, ReadPosition, WriteFileOptions, WatchEventType, WatchListener, F_OK, R_OK, W_OK, X_OK, COPYFILE_EXCL, COPYFILE_FICLONE, COPYFILE_FICLONE_FORCE, O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_DIRECTORY, O_NOATIME, O_NOFOLLOW, O_SYNC, O_DSYNC, O_SYMLINK, O_DIRECT, O_NONBLOCK, S_IFMT, S_IFREG, S_IFDIR, S_IFCHR, S_IFBLK, S_IFIFO, S_IFLNK, S_IFSOCK, S_IRWXU, S_IRUSR, S_IWUSR, S_IXUSR, S_IRWXG, S_IRGRP, S_IWGRP, S_IXGRP, S_IRWXO, S_IROTH, S_IWOTH, S_IXOTH, UV_FS_O_FILEMAP
declare module 'fs' {
~~~~~~~
    at https://cdn.esm.sh/v66/@types/node/fs.d.ts:22:1

    Conflicts are in this file.
    declare module 'fs' {
    ~~~~~~~
        at https://cdn.esm.sh/v69/@types/node/fs.d.ts:22:1

TS2300 [ERROR]: Duplicate identifier 'internal'.
    export = internal;
             ~~~~~~~~
    at https://cdn.esm.sh/v66/@types/node/stream.d.ts:1245:14

    'internal' was also declared here.
        export = internal;
                 ~~~~~~~~
        at https://cdn.esm.sh/v69/@types/node/stream.d.ts:1245:14

TS2300 [ERROR]: Duplicate identifier 'stream'.
    export = stream;
             ~~~~~~
    at https://cdn.esm.sh/v66/@types/node/stream.d.ts:1249:14

    'stream' was also declared here.
        export = stream;
                 ~~~~~~
        at https://cdn.esm.sh/v69/@types/node/stream.d.ts:1249:14

Found 21 errors.

Additional info

  • esm.sh version:
  • Deno version: deno 1.19.3 (release, x86_64-apple-darwin)

chmac avatar Mar 18 '22 16:03 chmac

Adding some context, I think the issue is with the types:

https://cdn.esm.sh/v69/[email protected]/index.d.ts

// TypeScript Version: 3.2

/// <reference types="node" lib="esnext" />

import * as fs from 'https://cdn.esm.sh/v69/@types/node/fs.d.ts';
import { Readable } from 'https://cdn.esm.sh/v69/@types/node/stream.d.ts';
...

I don't know if it's a general problem with the node fs types. But if I add ?no-check to the URL, then the import works fine, but I don't get any type info of course.

chmac avatar Mar 18 '22 16:03 chmac

I think one of the solutions could be replacing @types/node with std/node/fs imports

v1rtl avatar Mar 28 '22 16:03 v1rtl