0

Is there a way to read environment variable address in Node.js?

For example :

var env_addr = env_memory_address(process.env.PATH);

console.log(env_addr); // output: 0xbf832ff
12
  • What problem are you actually trying to solve by getting a memory address of an environment variable? I'm guessing there are much better ways to solve your actual problem that might even be feasible from Javascript, but we'd need to know the real problem in order to offer ideas. Please try not to post xy problems where you post a question about your imagined solution rather than posting about the actual problem. You get a lot less useful info from us when you hide the actual problem. Commented Feb 22, 2018 at 22:19
  • Actually there is not have a problem. Just wondering how far Node.js can go. Commented Feb 23, 2018 at 2:40
  • So then, did my answer below answer your question? Commented Feb 23, 2018 at 3:18
  • No. But thanks again for your answer. Commented Feb 23, 2018 at 3:45
  • For an answer like how to do it :P Commented Feb 23, 2018 at 3:50

1 Answer 1

1

Is there a way to read environment variable address in Node.js?

No, not from plain Javascript. Javascript itself does not surface memory addresses in any way either in the browser or in the node.js execution environment.

You could probably write a node.js add-on in C++ and could then get a memory address, but even if you surfaced it back to Javascript in some Javascript data type, you couldn't do anything with it directly in Javascript (other than pass it to other C++ add-on code) and you'd probably have to put a string-ized version of the address in a Javascript string variable because there is no other Javascript data type that's a good match for a 64-bit memory address. Or, you could make your own "handle" that had the address in it and was surfaced back to Javascript as an object. But, either way you couldn't do anything with the memory address in Javascript.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.