You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ node --require @babel/register --experimental-require-module use-npm-package.js
(node:179449) 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)
/home/dev/temp/babel-bugs/node_modules/p-map/index.js:1
export default async function pMap(
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (node:internal/modules/cjs/loader:1389:18)
at Module._compile (node:internal/modules/cjs/loader:1425:20)
at Module._compile (/home/dev/temp/babel-bugs/node_modules/pirates/lib/index.js:117:24)
at Module._extensions..js (node:internal/modules/cjs/loader:1523:16)
at Object.newLoader [as .js] (/home/dev/temp/babel-bugs/node_modules/pirates/lib/index.js:121:7)
at Module.load (node:internal/modules/cjs/loader:1287:32)
at Function.Module._load (node:internal/modules/cjs/loader:1103:12)
at Module.require (node:internal/modules/cjs/loader:1310:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/home/dev/temp/babel-bugs/use-npm-package.js:1:13)
at Module._compile (node:internal/modules/cjs/loader:1480:14)
at Module._compile (/home/dev/temp/babel-bugs/node_modules/pirates/lib/index.js:117:24)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Object.newLoader [as .js] (/home/dev/temp/babel-bugs/node_modules/pirates/lib/index.js:121:7)
at Module.load (node:internal/modules/cjs/loader:1287:32)
at Function.Module._load (node:internal/modules/cjs/loader:1103:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:168:12)
at node:internal/main/run_main_module:30:49
Node.js v22.1.0
Hey @avaly! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
馃捇
How are you using Babel?
@babel/register or @babel/node
Input code
use-npm-package.js
:use-local-module.js
:esm.mjs
:Configuration file name
No response
Configuration
No Babel config provided.
Current and expected behavior
Loading ESM modules from current directory
Current & expected behavior:
Loading ESM modules from
node_modules
Current behavior without
@babel/register
& Expected behavior with@babel/register
:Current behavior with
@babel/register
:Environment
System:
OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
Binaries:
Node: 22.1.0
npm: 10.7.0
npmPackages:
@babel/register: 7.23.7
p-map: 7.0.2
Possible solution
No response
Additional context
Support for
require()
ing ESM modules added in node.js v22: nodejs/node#51977The text was updated successfully, but these errors were encountered: