Created
September 25, 2018 08:00
-
-
Save tomasevich/1675eee92fd4b25265f728307f48ce93 to your computer and use it in GitHub Desktop.
Auto-install modules :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const { exec } = require ('child_process') | |
try { | |
const express = require ('express') | |
const ejs = require ('ejs') | |
var app = express () | |
app.listen (8080) | |
} catch (e) { | |
if (/^Cannot find module \'([a-z]{0,20})\'$/i.exec (e.message)) { | |
let name = /^Cannot find module \'([a-z]{0,20})\'$/i.exec (e.message)[1] | |
console.log (`install {${name}} module`) | |
exec (`npm i ${name} --save`) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
or auto load :)