babel/babel

[Bug]: Cannot find package '@babel/plugin-preset-env' imported

msidolphin opened this issue · 3 comments

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

{
  test: /\.tsx?$/,
  exclude: /node_modules/,
  use: [
  {
    loader: "babel-loader",
    options: {
      plugins: [
        ["@babel/plugin-transform-runtime", {
          "corejs": 3
        }],
        [
          "@babel/preset-env"
        ]
      ]
    }
  },

Configuration file name

No response

Configuration

{
    plugins: [
      ["@babel/plugin-transform-runtime", {
        "corejs": 3
      }],
      [
        "@babel/preset-env"
      ]
    ]
  }

Current and expected behavior

Why do I configure @babel/preset-env but keep getting a message that the '@babel/plugin-preset-env' package imported from xxx/build/babel-virtual-resolve-base.js cannot be found?

Environment

System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.10 - ~/.npm-global/bin/yarn
npm: 10.4.0 - ~/.npm-global/bin/npm
pnpm: 8.8.0 - ~/.npm-global/bin/pnpm
npmPackages:
@babel/core: ^7.24.4 => 7.24.4
@babel/plugin-transform-runtime: ^7.24.3 => 7.24.3
@babel/preset-env: ^7.24.4 => 7.24.4
@babel/runtime-corejs3: ^7.24.4 => 7.24.4
babel-loader: ^9.1.3 => 9.1.3

Possible solution

No response

Additional context

No response

Hey @msidolphin! 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.

image image

It looks like the babel-loader automatically adds the plugin keyword

You should move it to the presets array :)