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

Failed to import - cloudinary #253

Closed
aiotter opened this issue Jan 21, 2022 · 9 comments
Closed

Failed to import - cloudinary #253

aiotter opened this issue Jan 21, 2022 · 9 comments
Labels
deno Not working in Deno

Comments

@aiotter
Copy link

aiotter commented Jan 21, 2022

Failing module

import * as cloudinary from "https://esm.sh/cloudinary@1.28.1?no-check";

Error message

After running deno run I got this:

Download https://esm.sh/cloudinary@1.28.1?no-check
Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at https://cdn.esm.sh/v63/cloudinary@1.28.1/deno/cloudinary.js:16:24037
    at https://cdn.esm.sh/v63/cloudinary@1.28.1/deno/cloudinary.js:2:2780
    at https://cdn.esm.sh/v63/cloudinary@1.28.1/deno/cloudinary.js:16:24210

Additional info

  • esm.sh version: v63
  • Deno version: 1.17.2

When I tried to import it without ?no-check flag, the following error occurred:

error: TS2671 [ERROR]: Cannot augment module 'cloudinary' because it resolves to a non-module entity.
declare module 'cloudinary' {
               ~~~~~~~~~~~~
    at https://cdn.esm.sh/v63/cloudinary@1.28.1/types/index.d.ts:4:16

After import "https://deno.land/std@0.122.0/node/global.ts", process.versions.node.split(".") itself works successfully.
There seems to be a bug in node.js compartible layer in esm.sh.

@aiotter aiotter added the deno Not working in Deno label Jan 21, 2022
@ije
Copy link
Member

ije commented Jan 21, 2022

@aiotter thanks i will look into it

@ije
Copy link
Member

ije commented Jan 21, 2022

after added process.versions.node i got anther error:

Screenshot 2022-01-21 at 23 21 40

@ije
Copy link
Member

ije commented Jan 21, 2022

types seems to work for me:

Screenshot 2022-01-21 at 23 24 15

@ije ije closed this as completed in c2e488a Jan 21, 2022
@aiotter
Copy link
Author

aiotter commented Jan 22, 2022

Nice, it was so quick! Thanks ☺️

@aiotter
Copy link
Author

aiotter commented Jan 22, 2022

@ije It seems not working on both esm.sh and localhost yet.

esm.sh:

> import "https://esm.sh/v64/cloudinary"
Uncaught Error: Dynamic require of "proxy-agent" is not supported
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2751
    at Object.Qd [as optionalRequire] (https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:13:3076)
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:14:312
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2831
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:16:20836
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2831
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:16:24193
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2831
    at https://cdn.esm.sh/v64/cloudinary@1.28.1/deno/cloudinary.js:16:24210

localhost (10c10b9):

> import "http://localhost:8080/cloudinary"
Uncaught Error: Dynamic require of "proxy-agent" is not supported
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2751
    at Object.Qd [as optionalRequire] (http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:13:3076)
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:14:312
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2831
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:16:20836
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2831
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:16:24193
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:2:2831
    at http://localhost:8080/v64/cloudinary@1.28.1/deno/cloudinary.js:16:24210

@aiotter
Copy link
Author

aiotter commented Jan 27, 2022

@ije This is just a gentle reminder, but did you checked my report above? If this is a solvable problem on the esm.sh side, can you please reopen the issue?

@ije
Copy link
Member

ije commented Jan 27, 2022

i think i can not fix it, since esbuild rewrite the require function.
but i guess you can add a workaround for it:

import proxyAgent from "https://esm.sh/proxy-agent"
globalThis.require = (name) => {
  if (name == "proxy-agent") return proxyAgent
}

import "https://esm.sh/v64/cloudinary"

@ije
Copy link
Member

ije commented Jan 27, 2022

same as #257

@aiotter
Copy link
Author

aiotter commented Jan 27, 2022

Thank you for workaround! I appreciate it 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno Not working in Deno
Projects
None yet
Development

No branches or pull requests

2 participants