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

147
Views
How do I globally install a Node.js command-line script on the server?

As a prototype, I’ve written a simple Node.js command-line script which loads a .txt file and outputs the contents. I’ve read many articles which suggest that Node.js scripts are usually executed via the command-line and should be installed globally, so that’s the direction I’ve taken, even if there are other techniques.

For the sake of this query, my globally installed command is called my-prototype.

This all works fine on the desktop but I intend to host this prototype on a server, using Express.

How do I globally install my-prototype on the server and, if that’s possible, will I be able to execute it in the same way as in my local tests, as a child process?:

const { execSync } = require('child_process')
const output = execSync(`${process.execPath} my-prototype`)
console.log(output.toString())

I'm not entirely sure that globally installing command-line scripts is for use on a server and wonder whether that's for desktop use only.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you need just output the contents, then you do not need a console, or rather: you only need it once, to run nodejs

const fs = require('fs');

const express = require('express');
const app = express();

//

app.get('/', async(req, res)=>{
    let fileContains = fs.readFileSync('./package.json', 'utf8');
    try{
        fileContains = JSON.parse(fileContains);
    }catch(e){}
    res.json(fileContains);
});

//

app.listen(80);

Also, read a little more about the pm2 module, it's very useful

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!