Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Run a Node.JS in-memory script from Node JS code

I have 2 files , app.js and performance.js.

I want to put all the code of performance.js in memory , and whenever needed run requests that reach to app.js against the code of performance.js IN MEMORY.

Notice: I don't want to store a file in memory and then download it into a temporary file!

performance.js

function sum_two(a,b) { 
    return a+b;
}

module.exports = { 
    sum_two,
}

app.js:

// 1.Store performance.js in the memory somehow  // HAPPENS ONLY ONCE!
// 2.run against the memory the function sum_two // HAPPENS OVER AND OVER AGAIN
const res = sum_two(1,2);
console.log('Result:' , res);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use new vm.compileFunction(script)(), new Function(script)() or eval(script)

// Example with esbuild
esbuild.build(esbuildConfig).then(res => {
  res[0].outputFiles.map((f) => /\.m*js$/.test(f.path) && new vm.compileFunction(f.text)())
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!