O
O
Ostic2019-05-26 08:58:58
Node.js
Ostic, 2019-05-26 08:58:58

How to run npm package from node?

Hello.
How to run npm package from node?
That's how I can, but it's still npm in the end, but is it possible to run npm specifically with a node?

const { exec } = require('child_process');
exec('npm run package', (error, stdout, stderr) => {
  if (error) {
    console.error(`exec error: ${error}`);
    return;
  }
  console.log(`stdout: ${stdout}`);
  console.log(`stderr: ${stderr}`);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stockholm Syndrome, 2019-05-26
@StockholmSyndrome

npx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question