-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 import npm:@mobily/[email protected]
#17231
Labels
Comments
bartlomieju
added
needs investigation
requires further investigation before determining if it is an issue or not
node compat
labels
Jan 3, 2023
@scarf005 did you find any solution using npm? |
dsherret
changed the title
Cannot import Oct 21, 2024
'import', and 'export' cannot be used outside of module code
when importing from npm
npm:@mobily/[email protected]
dsherret
added
invalid
what appeared to be an issue with Deno wasn't
and removed
needs investigation
requires further investigation before determining if it is an issue or not
labels
Oct 21, 2024
Investigated and this package's ESM build is broken and doesn't work in Node.js either. > touch package.json
> deno install npm:@mobily/[email protected]
> echo 'import * as test from '@mobily/ts-belt'; console.log(test)' > main.mjs
> deno run main.mjs
error: [ERR_UNSUPPORTED_DIR_IMPORT] Directory import 'file:///V:/scratch/node_modules/.deno/@[email protected]/node_modules/@mobily/ts-belt/dist/esm/Function' is not supported resolving ES modules imported from 'file:///V:/scratch/node_modules/.deno/@[email protected]/node_modules/@mobily/ts-belt/dist/esm/index.js'
> node main.mjs
(node:39952) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
V:\scratch\node_modules\.deno\@[email protected]\node_modules\@mobily\ts-belt\dist\esm\index.js:1
import { pipe } from "./pipe.js";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (node:internal/modules/cjs/loader:1376:18)
at Module._compile (node:internal/modules/cjs/loader:1405:20)
at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
at Module.load (node:internal/modules/cjs/loader:1275:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
at cjsLoader (node:internal/modules/esm/translators:318:5)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:258:7)
at ModuleJob.run (node:internal/modules/esm/module_job:262:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:474:24)
Node.js v22.3.0
> node --experimental-detect-module main.mjs
node:internal/modules/esm/resolve:254
throw new ERR_UNSUPPORTED_DIR_IMPORT(path, fileURLToPath(base), String(resolved));
^
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'V:\scratch\node_modules\.deno\@[email protected]\node_modules\@mobily\ts-belt\dist\esm\Function' is not supported resolving ES modules imported from V:\scratch\node_modules\.deno\@[email protected]\node_modules\@mobily\ts-belt\dist\esm\index.js
at finalizeResolution (node:internal/modules/esm/resolve:254:11)
at moduleResolve (node:internal/modules/esm/resolve:920:10)
at defaultResolve (node:internal/modules/esm/resolve:1119:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:541:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49) {
code: 'ERR_UNSUPPORTED_DIR_IMPORT',
url: 'file:///V:/scratch/node_modules/.deno/@[email protected]/node_modules/@mobily/ts-belt/dist/esm/Function'
}
Node.js v22.3.0 The package's ESM export needs to be updated to work or it should be removed and the package should only ship CJS. Follow mobily/ts-belt#117 for updates. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To reproduce
would there be a reason why
esm.sh
works butnpm:
specifier does not?Error log
index.js
The text was updated successfully, but these errors were encountered: