denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
95.44k stars 5.3k forks source link

could not resolve npm package #17424

Open sigmaSd opened 1 year ago

sigmaSd commented 1 year ago
> 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

sigmaSd commented 1 year ago

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)

image

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/std@0.172.0/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

sigmaSd commented 1 year ago

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
>
popuguytheparrot commented 1 year ago

i got same error with @hono/zod-openapi image

RoXuS commented 1 year ago
TypeError: Could not resolve 'npm:@material/web@1.0.0'.
  Caused by:
    not found

same here

insanity54 commented 10 months ago

Curiously I only see this problem on less-common npm packages, like one of my own published npm modules.

error: Could not resolve 'npm:prevvy@7.5.0'.
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?

nbbaier commented 8 months ago

I'm experiencing the same issue with a package I published recently:

error: Could not resolve 'npm:tana-to-json@0.3.0'.

Caused by:
    not found

npm install tana-to-json works fine as expected

sigmaSd commented 6 months ago
import * as pl from "npm:@pola-rs/browser";

doesn't error anymore but adding console.log(pl); it errors with Not found