Skip to content

Deprecation Warning: lodash.get is deprecated, use optional chaining (?.) instead #3634

@doshibadev

Description

@doshibadev

The [FAQ](https://github.com/PrismarineJS/mineflayer/blob/master/docs/FAQ.md) doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.27.0
  • server: folia 1.20.1
  • node: 22.14.0

Detailed description of problem

I'm encountering a deprecation warning in the mineflayer library due to the usage of the deprecated lodash.get package. The warning indicates that lodash.get is no longer maintained and should be replaced with optional chaining (?.), as it is the modern, preferred method for accessing deeply nested properties in JavaScript.

Warning Message:

npm WARN deprecated lodash.get@4.4.2: This package is deprecated. Use the optional chaining (?.) operator instead.

What I'm building:

I'm using mineflayer to create a Minecraft bot, and during the installation and usage of the library, I receive the deprecation warning about lodash.get. This affects the smooth running of my project as I want to ensure my dependencies are up-to-date and do not use deprecated packages.

What did you try yet?

I have tried updating mineflayer to the latest version, but the deprecation warning persists because lodash.get is still in use within the codebase.

Your current code

// Example of using mineflayer code where lodash.get is used
const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25565,
  username: 'Bot'
});
// A hypothetical example where lodash.get is used
const value = _.get(bot, 'entity.position.x');

Expected behavior

I expect the deprecation warning to be resolved by replacing lodash.get with optional chaining (?.). For example:

const value = bot?.entity?.position?.x;

Additional context

The lodash.get package is deprecated, and its usage can be replaced with the modern optional chaining operator (?.) in the JavaScript codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stage1just created by someone new to the project, we don't know yet if it deserves an implementation / a fpossible bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions