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

Cannot use Minio in Deno #1261

Closed
riderx opened this issue Feb 5, 2024 · 7 comments
Closed

Cannot use Minio in Deno #1261

riderx opened this issue Feb 5, 2024 · 7 comments

Comments

@riderx
Copy link

riderx commented Feb 5, 2024

IT's now allowed to use in Deno:

import { Client } from 'npm:minio'

function initR2(c: Context) {
  const accountid = '*****'
  const access_key_id = '*****'
  const access_key_secret = '*****'
  const params = {
    endPoint: `${accountid}.r2.cloudflarestorage.com`,
    region: 'us-east-1',
    useSSL: true,
    accessKey: access_key_id,
    secretKey: access_key_secret,
  }

  console.log('R2 params', params)
  const client = new Client(params)
  console.log('R2 client', client)
  return client
}
initR2()

And then i get error like that:

e Error: unreachable
    at arch (ext:deno_node/_process/process.ts:16:11)
    at get arch [as arch] (node:process:275:14)
    at new TypedClient (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/minio/7.1.3/dist/esm/internal/client.mjs:98:62)
    at new Client (file:///tmp/sb-compile-edge-runtime/node_modules/localhost/minio/7.1.3/dist/esm/minio.mjs:44:8)
@aldy505
Copy link
Contributor

aldy505 commented Feb 7, 2024

The SDK requires some Node.js dependencies. See here

import * as crypto from 'node:crypto'
import * as fs from 'node:fs'
import * as http from 'node:http'
import * as https from 'node:https'
import * as path from 'node:path'
import * as stream from 'node:stream'

Perhaps Deno support will be available sooner or later. I don't have any idea about that.

@riderx
Copy link
Author

riderx commented Feb 7, 2024

Deno does support node deps since a year :)
https://docs.deno.com/runtime/manual/node/compatibility
It seems the problem is not them, maybe one of the other npm deps.
Maybe fs is problematic also.

can I try to work on it ?

@aldy505
Copy link
Contributor

aldy505 commented Feb 8, 2024

Sure go ahead. But the typescript rewrite has been going really slow right now.

@riderx
Copy link
Author

riderx commented Feb 9, 2024

I'm not sure to understand what you mean by "typescript rewrite" ?

@riderx
Copy link
Author

riderx commented Feb 9, 2024

I just realized it works in Deno with ESM magic!

Just import like that

import { Client } from "https://esm.sh/minio?target=deno"

TADA :)

@riderx
Copy link
Author

riderx commented Feb 12, 2024

For the record here is the issue i get on Deno or Cloudflare workers env:
CleanShot 2024-02-12 at 22 45 24@2x
I created a PR to address all of these issue here:
#1265

@yurkimus
Copy link

I just realized it works in Deno with ESM magic!

Just import like that

import { Client } from "https://esm.sh/minio?target=deno"

TADA :)

Thank you!

And the types

deno.json

{
  "imports": {
    "minio": "https://esm.sh/[email protected]?target=deno"
  },

  "vendor": true
}

index.js

// @deno-types="https://esm.sh/v135/@types/[email protected]/index.d.ts"
import { Client } from 'minio'

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

No branches or pull requests

3 participants