#How to handle npm packages that rely on process.env?

10 messages · Page 1 of 1 (latest)

copper relic
#

I tried using antd in a fresh (https://fresh.deno.dev) project, but got the error TypeError: Cannot read properties of undefined (reading 'env'). It's my first time attempting to use deno in a project. My guess is that process.env does not exist in Deno. However, this is very commonly used in the node world, and if Deno supports node packages, then there's likely a way around it, right?

scenic dome
#

try running main.ts manually (deno run -A ./main.ts) to see if it happens

copper relic
#

running main.ts, i think i'm getting past that error, but getting a different one now Error: Invalid type passed to createElement(): [object Object]. it looks like dev.ts might indeed be the issue here.

The only change I've made to the starter project is in Counter.tsx.

// import { Button } from "../components/Button.tsx";
import { Button } from "npm:antd";
scenic dome
#

you should probably be using esm.sh for that library

#

with preact compat

#
{
    "imports": {
        "react": "https://esm.sh/preact@10.15.1/compat",
        "antd": "https://esm.sh/antd@5.7.0&external=react"
    }
}```
copper relic
#

hmm same error. do i need to change the import path as well?

#

i tried just antd instead of npm:antd to match what's specified in the resolver. looks like i've made some progress 😅

error: error sending request for url (https://esm.sh/v128/rc-util@5.34.1/X-ZS9yZWFjdA/denonext/es/hooks/useId.js): http2 error: connection error received: unspecific protocol error detected
    at https://esm.sh/v128/rc-dialog@9.1.0/X-ZS9yZWFjdA/denonext/rc-dialog.mjs:2:736
#

and of course, visiting those links in the browser work. it shouldnt be a network issue