wll8 / sync-package

Dynamically install dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamically install dependencies

use

const { initPackge } = require(`@wll8/sync-package`)

new Promise(async () => {
  const pkg = await initPackge(`lodash`, {
    mainPath: __dirname,
  })
  console.log(`pkg`, pkg.set)
})

parameter

/**
 * @param {string} pkg The dependencies to be installed. It is actually the same as the parameter after npm i
 * @param {object} param1 configuration
 * @param {boolean} param1.getRequire Whether to require after the installation is complete
 * @param {boolean} param1.requireName The name used when require. The default is automatic resolution. When using url to install, the program does not know the real name, and it needs to be specified at this time
 * @param {object} param1.env Environment variables during installation
 * @param {string} param1.mainPath what directory to install
 */
initPackge(pkg, param1)

License

MIT

Copyright (c) 2017-present, xw

About

Dynamically install dependencies


Languages

Language:JavaScript 100.0%