Package: node-babel7
Version: 7.20.15+ds1+~cs214.269.168-6

I'm trying to use a project that uses babel, importing it as a module as
stated on babel docs [1]:

However, when loading something as simple as:

❯ cat /tmp/foo.mjs
import { transform } from "@babel/core";

console.log(transform)

❯ node /tmp/babel.mjs  
node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@babel/core' imported
from /tmp/babel.mjs
Did you mean to import @babel/core/lib/index.js?
    at new NodeError (node:internal/errors:405:5)
    at packageResolve (node:internal/modules/esm/resolve:916:9)
    at moduleResolve (node:internal/modules/esm/resolve:973:20)
    at defaultResolve (node:internal/modules/esm/resolve:1193:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:403:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:372:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:249:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:39)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v18.19.0

---

Now, using require("@babel/core") things work, but indeed, it (and its
plugisn) should work as ES modules too.


[1] https://babeljs.io/docs/babel-core

Reply via email to