Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
doshibadev opened this issue Apr 5, 2025 · 8 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@doshibadev
Copy link

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 [email protected]: 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.

@doshibadev doshibadev added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Apr 5, 2025
@extremeheat
Copy link
Member

mineflayer doesn't import this package, the issue is upstream and should be opened there instead

@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

// A hypothetical example where lodash.get is used

Well that's the problem, give the real location and it can be fixed

@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

I built https://v0-npm-package-path-visualizer-alrf2c.vercel.app/ with v0 to find the path

@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

Image

@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

Chatgpt take PrismarineJS/node-minecraft-protocol#1390

@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

Well I really want to just ask an agent to do this stuff end to end

@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

Fixed

@rom1504 rom1504 closed this as completed Apr 6, 2025
@rom1504
Copy link
Member

rom1504 commented Apr 6, 2025

Image

Confirmed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

3 participants