What career option is secure investment for next two decades?
As an experienced Frontend engineer, I find this career extremely fluctuating and ruthless at times. Things are constantly changing, with lower barrier of entry, and market flooded with thousands of Frontend engineers.
Can someone please suggest on which career path is safer and stable learning investment for next 10-20 years?
This won't be the answer you're looking for, but:
You already correctly realized that the only sure thing is constant change :) Therefore, seek to create the safety you're longing for by embracing and optimizing for change. So for you, that could mean that you take inventory of: professional contacts, knowledge about specific industries and their pain points (e.g. from clients you worked for), pain points of people of a certain niche you are familiar with; and of course there's your unique skill set (not just your professional frontent tech knowledge). Harnessing your inventory, you start working on your own projects (plural!). Don't focus on "monetizing", but on creating action and soothing the pain points you identified. You'll learn the really valuable things on the go, as they become requirements for you to continue your way.
Healthcare. Maybe for someone with your experience you might be well suited to bio-mechanical engineering