babel / babel

🐠 Babel is a compiler for writing next generation JavaScript.
https://babel.dev
MIT License
43.18k stars 5.64k forks source link

[Bug]: _traverse.visitors.environmentVisitor is not a function. #16851

Open jaydevnani opened 2 hours ago

jaydevnani commented 2 hours ago

💻

How are you using Babel?

babel-loader (webpack)

Input code

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _helperMemberExpressionToFunctions = require("@babel/helper-member-expression-to-functions");
var _helperOptimiseCallExpression = require("@babel/helper-optimise-call-expression");
var _core = require("@babel/core");
var _traverse = require("@babel/traverse");
const {
  assignmentExpression,
  callExpression,
  cloneNode,
  identifier,
  memberExpression,
  sequenceExpression,
  stringLiteral,
  thisExpression
} = _core.types;
{
  exports.environmentVisitor = _traverse.visitors.environmentVisitor({});
  exports.skipAllButComputedKey = function skipAllButComputedKey(path) {
    path.skip();
    if (path.node.computed) {
      path.context.maybeQueue(path.get("key"));
    }
  };
}

Configuration file name

No response

Configuration

No response

Current and expected behavior

Current output in shell:

error src/main.tsx: _traverse.visitors.environmentVisitor is not a function.
TypeError: _traverse.visitors.environmentVisitor is not a function
    at Object.<anonymous> (/Users/jaydevnani/Desktop/mobile/node_modules/@babel/helper-replace-supers/lib/index.js:22:51)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)

Process finished with exit code 1

Expected behavior: Process finished with exit code 0

Environment

All versions installed using yarn

Possible solution

No response

Additional context

No response

babel-bot commented 2 hours ago

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

JLHwung commented 1 hour ago

_traverse.visitors.environmentVisitor is available in @babel/traverse 7.25.0, please update @babel/traverse.