0

How to run npm funct from js file

  • 1
    Possible duplicate of [Execute a command line binary with Node.js](https://stackoverflow.com/questions/20643470/execute-a-command-line-binary-with-node-js) – Ivan Bacher Jul 26 '18 at 09:36

1 Answers1

1

Yes, you can do this, here is the code:

var execSync = require('child_process').execSync;

var list = execSync('yarn list', { encoding: 'utf-8' });
console.log(list);
Viktor Vlasenko
  • 1,962
  • 10
  • 15