How to install npm package from nodejs script?
Question is not about simple installation npm packages via terminal,
it is about installation via nodejs script:
Not about this: npm install express, but about having install.js file with content npm install express, which I will execute like node install.js and after this it will locally install express module in this folder.
Sorry, but Google and DuckDuckGo are not my friends today(
The main problem is in automatic local installation required packages for my small utility, because global packages are not working in windows.
Check out commander.js it allows you to write command line apps using node.
Then you can use the
execmodule.Assuming you put the following in
install.js, you just have to do:./install.jsand it will runnpm installfor you.Hope this helps!