deno
deno copied to clipboard
could not resolve npm package
> import * as pl from "npm:@pola-rs/browser"
✅ Granted env access to "NODE_CLUSTER_SCHED_POLICY".
✅ Granted env access to "NODE_UNIQUE_ID".
Uncaught TypeError: Could not resolve 'npm:@pola-rs/browser'.
Caused by:
not found
at async <anonymous>:2:12
but it seems to exist https://www.npmjs.com/package/@pola-rs/browser?activeTab=readme
using strace I can see that deno looks for inedx.js but there is only browser.js
statx(AT_FDCWD, "/home/mrcool/.cache/deno/npm/registry.npmjs.org/@pola-rs/browser/0.0.1-alpha/index.js", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc31a5f930) = -1 ENOENT (Aucun fichier ou dossier de ce type)

If I copy browser.js to index.js I get another error
Deno 1.29.3+1712a88
exit using ctrl+d, ctrl+c, or close()
> import * as pl from "npm:@pola-rs/browser"
error: TypeError: Could not resolve 'https://deno.land/[email protected]/node/module_all.ts' from 'file:///home/mrcool/.cache/deno/npm/registry.npmjs.org/@pola-rs/browser/0.0.1-alpha/[deno:cli/node/mod.rs:412:32]'.
Caused by:
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLS are supported by the default ESM loader. Received protocol 'https'
at async loadBuiltinNodeModules ([deno:cli/node/mod.rs:412:32]:2:25)
>
EDIT: This error is unrelated, it happens because I run deno inside ~/.cache/deno/npm
If I copy browser.js to index.js this is the error
Deno 1.29.3+1712a88
exit using ctrl+d, ctrl+c, or close()
> import * as pl from "npm:@pola-rs/browser"
Uncaught TypeError: 'import', and 'export' cannot be used outside of module code at file:///home/mrcool/.cache/deno/npm/registry.npmjs.org/@pola-rs/browser/0.0.1-alpha/index.js:1:1
import { startWorkers } from './snippets/wasm-bindgen-rayon-7afa899f36665473/src...
~~~~~~
at async <anonymous>:2:12
>
i got same error with @hono/zod-openapi
Curiously I only see this problem on less-common npm packages, like one of my own published npm modules.
error: Could not resolve 'npm:[email protected]'.
Caused by:
not found
I had no problem with a more popular module such as date-fns
import { isBefore } from 'npm:date-fns'; // this works
Is there any fix for this, or anything I can do to help find a solution?
I'm experiencing the same issue with a package I published recently:
error: Could not resolve 'npm:[email protected]'.
Caused by:
not found
npm install tana-to-json works fine as expected
import * as pl from "npm:@pola-rs/browser";
doesn't error anymore
but adding console.log(pl); it errors with Not found