3

In my script I have

const mysql = require('mysql');

Is there a way to install mysql in runtime (if not installed yet) ? I read this solution: Is it possible to install npm package only if it has not been already installed?

But this is done through shell and not applicable in windows I look for a windows version.

My goal is to provide scripts to my client - he is unable to lunch some npm commands to install packages.

yarek
  • 11,278
  • 30
  • 120
  • 219

1 Answers1

0
npm list mysql || npm install mysql

npm list <package> will return └── (empty) (Node.js v10.15.3) if package does not exist.

Umair Sarfraz
  • 5,284
  • 4
  • 22
  • 38