denoland / deno

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

npm URL of @progfay/scrapbox-parser throws ERR_MODULE_NOT_FOUND #24843

Closed takker99 closed 2 months ago

takker99 commented 2 months ago

https://www.npmjs.com/package/@progfay/scrapbox-parser

$ deno --version
deno 1.45.5 (release, x86_64-unknown-linux-gnu)
v8 12.7.224.13
typescript 5.5.2

$ deno
Deno 1.45.5
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import { parse } from "npm:@progfay/scrapbox-parser@9"
Uncaught TypeError: [ERR_MODULE_NOT_FOUND] Cannot find module '/root/.cache/deno/npm/registry.npmjs.org/@progfay/scrapbox-parser/9.0.0/esm/parse' imported from '/root/.cache/deno/npm/registry.npmjs.org/@progfay/scrapbox-parser/9.0.0/esm/index.js'
    at async <anonymous>:1:40

$ exa ~/.cache/deno/npm/registry.npmjs.org/@progfay/scrapbox-parser/9.0.0/esm/
block  index.d.ts  index.d.ts.map  index.js  index.js.map  parse.d.ts  parse.d.ts.map  parse.js  parse.js.map

According to https://github.com/denoland/deno/issues/16658#issuecomment-1316825629, this bug already seemed to be fixed. However, I got the above error so it seems not to be fixed completely.

dsherret commented 2 months ago

The ESM output of this package is wrong and doesn't work in Node. Deno is a bit more lenient about loading files that appear to be ESM, but if I tell node that this folder is supposed to be ESM then I get the same error that appears in Deno when importing this package from ESM Node:

% node index.mjs
node:internal/modules/esm/resolve:260
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/.../node_modules/@progfay/scrapbox-parser/esm/parse' imported from /.../node_modules/@progfay/scrapbox-parser/esm/index.js

This is because it needs to import parse.js instead of parse when importing an ES module in Node.

takker99 commented 2 months ago

Thank you for your answer. I clearly got it! Fortunately, after creating the issue, I found that this package was also published on JSR, so I use it.