Install new NPM package
@param {String} packageName
@return {Promise<any>}
321350
function npmInstall(packageName)
{
    return new Promise((resolve,reject) => {
        
        npm.load({
            save:false,
			progress: false,
            force:true
        }, function (er) {
            if (er)
            {
                PAILogger.error(er);
				return reject(er);
			}
            
            npm.commands.install([packageName], function (er, data) {
                if (er) {
					PAILogger.error(er);
					return reject(er);
                }
                resolve(data);
                // command succeeded, and data might have some info
            });
            
        });
        
    });
}
413366
function (packageid) {
    return this.get('/packagedetails', {
      'cc': this.options.country,
      'l': this.options.language,
      'packageids': packageid
    }).then(function (body) {
      var data = body[packageid].data;
      return Promise.resolve(data);
    });
  }
899916
function npmInstall(requires, done) {
    var npmBin = path.join(path.dirname(process.argv[0]), 'npm');
    if (process.platform === 'win32') { npmBin += '.cmd'; }
    async.forEachSeries(requires, function(module, next) {
      // skip existing modules
      if (grunt.file.exists(path.join('./node_modules/' + module))) {
        grunt.log.writeln(String('Module "' + module + '" already installed, skipping.').cyan);
        return next();
      }
      grunt.log.writeln('npm install ' + module + ' --save');
      // spawn npm install
      var s = grunt.util.spawn({
        cmd: npmBin,
        args: ['install', module, '--save']
      }, next);
      // write output
      s.stdout.on('data', function(buf) { grunt.log.write(String(buf)); });
      s.stderr.on('data', function(buf) { grunt.log.write(String(buf)); });
    }, done);
  }
545350
function Package(name)
    {
        var dotBowerJson = Package._readBowerJson(name) || {};
        var overrides = globalOverrides[name] || {};

        this.name         = name;
        this.installed    = !! dotBowerJson.name;
        this.main         = overrides.main || dotBowerJson.main || [];
        this.dependencies = overrides.dependencies || dotBowerJson.dependencies || [];
    }
1168814
function App(opts) {
    opts = opts || {};

    var path = opts.path || PATH.dirname(require.main.filename);

    // provides ym define&require interface
    var ym = YM.create();

    /**
     * @api
     * @param {string} moduleName
     * @param {string[]} [dependencies]
     * @param {function(function(*, ?Error=), ...*)} declarationFunction
     */
    this.define = ym.define;

    /**
     * @api
     * @param {string[]} dependencies
     * @param {function(Array<*>)} successCallbackFunction
     * @param {function(Error)} [errorCallbackFunction]
     */
    this.require = ym.require;

    /**
     * Loads node package with module provisions
     * @api
     * @param {(string|string[]|Object|Function)} pkg - package name, or list of,
     *   or package object, or package function
     * @returns {PYM} this
     */
    this.usePackage = function usePackage(pkg, options) {
        options = options || {};

        var resolvedPackage = _resolvePackageSync(path, pkg);
        resolvedPackage.exports(this, options);

        return this;
    };

    // load required modules if passed
    if (opts.uses) {
        if (Array.isArray(opts.uses)) {
            opts.uses.forEach(function (plugin) {
                this.usePackage(plugin);
            }, this);
        } else if (typeof opts.uses === 'object') {
            Object.keys(opts.uses).forEach(function (key) {
                this.usePackage(key, opts.uses[key]);
            }, this);
        } else {
            throw new Error('Unsupported value in uses property');
        }
    }
}
393424
function processLinked(deps, processed) {
      if(_.isEmpty(deps)) {
        return;
      }
      if(!processed) {
        processed = _.clone(deps);
      }

      var newDeps = {};
      var promise = when.resolve();
      _.each(deps, function(version, link) {
        promise = promise.then(function() {
          var pkgPath = path.resolve(nodeModulesDir, link, 'package.json');
          if (!fs.existsSync(pkgPath)) { throw new Error('Invalid package at '+pkgPath); }
          var linkPackage = require(pkgPath);

          if(!_.isEmpty(linkPackage.peerDependencies)) {
            //Install OR link peer dependencies
            self.log.verbose("Installing peer dependencies " +
              JSON.stringify(_.keys(linkPackage.peerDependencies)) + " from "
              + linkPackage.name + "@" + linkPackage.version + " into " + cwd);
          }

          return self.installWorkspaceDependencies(cwd, linkPackage.peerDependencies, workspaceDescriptor, installed)
          .then(function(newResults) {
            _.extend(newDeps, newResults.linked);
          });
        });
      });

      return promise.then(function() {
        var diff = _.omit(newDeps, _.keys(processed));
        //update the global list
        var newProcessed = _.extend({}, processed, diff);
        //process only new links
        return processLinked(diff, newProcessed);
      });
    }
739072
def check_npm_package!
      exit_status = Open3.capture2("node", "--eval", npm_package_require_snippet)[1]

      unless exit_status.success?
        raise engine::CompilerError, \
          %{No #{ engine.name } NPM package has been found in your system. } +
          %{Have you forgotten to "npm install --global #{ npm_package_name }"?}
      end
      nil
    end
350962
function installVer(name, ver, dir) {
        var _child$spawnSync2 = _child_process2['default'].spawnSync(npmCommand, ['install', name + '@' + ver], { cwd: dir });

        var error = _child$spawnSync2.error;

        if (error) throw error;
    }
274897
function definePackage(name, dependencies, callback) {
    // Adjust arguments
    if (typeof name === "function") {
        callback = name;
        name = null;
        dependencies = null;
    } else if (typeof dependencies === "function") {
        callback = dependencies;
        dependencies = null;

        if (name instanceof Array) {
            dependencies = name;
            name = null;
        }
    }

    // Check name conflicts
    if (typeof name === "string") {
        if (packages.has(name)) {
            throw new Error("Package '" + name + "' is already loaded!");
        }
    }

    // Resolve timeout
    var timeout = _config2.default.get('package_timeout', 5000),
        timer = null;

    return new _es6Promise.Promise(function (succeed, fail) {

        // Start timeout
        if (typeof timeout === "number") {
            timer = setTimeout(function () {
                timer = null;

                if (_config2.default.get("debug", true)) {
                    throw new Error("Package '" + name + "' timed out!");
                }
            }, timeout);
        }

        // Resolve dependencies
        requireDependencies(dependencies).then(function (requirements) {
            try {

                // register package
                var register = function register(pack) {
                    // cancel timeout
                    if (timer) {
                        clearTimeout(timer);
                        timer = null;
                    }

                    if (pack === false) {
                        return;
                    }

                    if (typeof name === "string") {
                        packages.set(name, pack);
                        events.emit("load:" + name, packages.get(name));
                    }

                    return succeed(pack);
                };

                // Check boot response


                var bootResponse = typeof callback === "function" ? callback(requirements) : callback;return bootResponse instanceof _es6Promise.Promise ? bootResponse.then(register) : register(bootResponse);
            } catch (ex) {
                if (_config2.default.get("debug", true)) {
                    console.error(ex);
                }

                return fail(ex);
            }
        });
    });
}
1308060
function providePromise(obj, providePromiseName) {
    if(!isString(providePromiseName)) {
      throw new Error('Must provide string as name of promised module');
    }
    di.annotate(obj, new di.ProvidePromise(providePromiseName));
  }
1271653
function writePackageVersion(newVersion) {
  var packageJson = path.join(process.cwd(), 'package.json'),
    raw = require(packageJson);

  raw.version = newVersion;

  fs.writeFileSync(packageJson, JSON.stringify(raw, null, 2));
}
328137
public static function installPackage($packageName, $constraint = 'dev-master')
	{
		if (self::_requirePackage($packageName, $constraint))
		{
			self::_resetComposer();
			return self::_updatePackage($packageName);
		}
		return false;
	}
76744
function promiseCommand(command) {
    const opts = {
        env: process.env
    };
    console.log('>>>>', command)
    return spawnShell(command, opts).exitPromise
        .then((exitCode) => {
            if (exitCode === 0) {
                return;
            } else {
                throw Error("Exit " + exitCode)
            }
        })
}
1248476
function addAPILinkToReadme(packageName) {

    var readmePath = path.join(destDir, packageName, 'README.md');
    var apiLink = "api";

    var usageText = 
        "\n" + 
        `[API Reference](${apiLink})`;

    fs.appendFile(readmePath, usageText, function (err) {
        if (err) {
            console.log(chalk.red(err));
        } 
    })

}
592885
function createPackage(next) {
    var pkg = JSON.parse(fs.readFileSync(path.join(scaffold, 'package.json'), 'utf8'));

    pkg.dependencies.flatiron = flatiron.version;

    flatiron.common.mixin(pkg, info);

    app.log.info('Writing ' + 'package.json'.grey);
    fs.writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2) + '\n', next);
  }
625560
function install(context) {
    // set properties
    const q = context.requireCordovaModule("q");
    var async = new q.defer(); // eslint-disable-line
    const installFlagLocation = path.join(
      context.opts.projectRoot,
      "plugins",
      context.opts.plugin.id,
      INSTALLFLAGNAME
    );
    const dependencies = require(path.join(
      context.opts.projectRoot,
      "plugins",
      context.opts.plugin.id,
      "package.json"
    )).dependencies;

    // only run once
    if (getPackageInstalled(installFlagLocation)) return;

    // install node modules
    const modules = getNodeModulesToInstall(dependencies);
    if (modules.length === 0) return async.promise;

    installNodeModules(modules, () => {
      // only run once
      setPackageInstalled(installFlagLocation);
      removeEtcDirectory();
      async.resolve();
    });

    // wait until callbacks from the all the npm install complete
    return async.promise;
  }
217364
function installPlugin(book, plugin) {
    var logger = book.getLogger();

    var installFolder = book.getRoot();
    var name = plugin.getName();
    var requirement = plugin.getVersion();

    logger.info.ln('');
    logger.info.ln('installing plugin "' + name + '"');

    // Find a version to install
    return resolveVersion(plugin)
    .then(function(version) {
        if (!version) {
            throw new Error('Found no satisfactory version for plugin "' + name + '" with requirement "' + requirement + '"');
        }

        logger.info.ln('install plugin "' + name +'" (' + requirement + ') from NPM with version', version);
        return Promise.nfcall(npmi, {
            'name': plugin.getNpmID(),
            'version': version,
            'path': installFolder,
            'npmLoad': {
                'loglevel': 'silent',
                'loaded': true,
                'prefix': installFolder
            }
        });
    })
    .then(function() {
        logger.info.ok('plugin "' + name + '" installed with success');
    });
}