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 - pg (https://www.npmjs.com/package/pg) #684

Open
bryiac opened this issue Jul 19, 2023 · 5 comments
Open

Failed to import - pg (https://www.npmjs.com/package/pg) #684

bryiac opened this issue Jul 19, 2023 · 5 comments
Labels
deno Not working in Deno

Comments

@bryiac
Copy link

bryiac commented Jul 19, 2023

Failing module

import { Client } from "https://esm.sh/pg"

Error message

After running deno run I got this:

error: Uncaught SyntaxError: The requested module 'https://esm.sh/pg' does not provide an export named 'Client'
import { Client } from "https://esm.sh/pg";
         ^
    at <anonymous> (file:///C:/Users/~/Desktop/temp/backend/src/util/postgres.ts:1:10)

After updating the import to "https://esm.sh/pg?cjs-exports=Client" I got this:

error: Uncaught Error: Could not find module root given file: "https://esm.sh/v128/bindings@1.5.0/denonext/bindings.mjs". Do you have a `package.json` file?                                                                                                                    
    at Function.l.getRoot (https://esm.sh/v128/bindings@1.5.0/denonext/bindings.mjs:9:620)                                              
    at P (https://esm.sh/v128/bindings@1.5.0/denonext/bindings.mjs:7:2170)
    at https://esm.sh/v128/libpq@1.8.12/denonext/libpq.mjs:9:916
    at https://esm.sh/v128/libpq@1.8.12/denonext/libpq.mjs:9:452
    at https://esm.sh/v128/libpq@1.8.12/denonext/libpq.mjs:9:4702

Additional info

  • esm.sh version: latest?
  • Deno version: 1.35.1
@bryiac bryiac added the deno Not working in Deno label Jul 19, 2023
@bryiac
Copy link
Author

bryiac commented Jul 19, 2023

Does esm.sh even work with bindings actually?

@renhiyama
Copy link
Contributor

Does esm.sh even work with bindings actually?

I believe no. Node gyp bindings will eventually try to use __filename / __dirname (depends on how code is written/generated by devs) and will try to load node native addon file. I think esm.sh doesn't run the build task that generates native node addon, and it would ofc depend on different cpu architecture and whether deno supports napi or not. I think it's beyond the scope of esm.sh to support native node addons.

@bryiac
Copy link
Author

bryiac commented Jul 19, 2023

Figured out it works using the npm:pg specifier though its missing typing's ~ also on the notes of deno supporting napi it seems like they do denoland/deno#13633 ~ wondering now if it would be possibility for this to work on esm.sh?

This package also says it supports a pure javascript implementation without the bindings

@bryiac
Copy link
Author

bryiac commented Jul 20, 2023

@ije any input on this not currently able to use the npm: specifier because its not currently available on deno deploy

@ije
Copy link
Member

ije commented Jul 20, 2023

@bryiac i will check

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

3 participants