Installs the NPM. The NPM is installed using {@code npm install npm@version}, without the {@code -g} option.
The installation is executed from the installation directory of node.
12810
private void install() {
        File directory = getNPMDirectory();
        if (directory.isDirectory()) {
            // Check the version
            String version = getVersionFromNPM(directory, log);
            // Are we looking for a specific version ?
            if (npmVersion != null) {
                // Yes
                if (!npmVersion.equals(version)) {
                    log.info("The NPM " + npmName + " is already installed but not in the requested version" +
                            " (requested: " + npmVersion + " - current: " + version + ") - uninstall it");
                    try {
                        FileUtils.deleteDirectory(directory);
                    } catch (IOException e) { //NOSONAR
                        // ignore it.
                    }
                } else {
                    log.debug("NPM " + npmName + " already installed in " + directory.getAbsolutePath() +
                            " (" + version + ")");
                    return;
                }
            } else {
                // No
                log.debug("NPM " + npmName + " already installed in " + directory.getAbsolutePath() + " " +
                        "(" + version + ")");
                return;
            }
        }

        StringBuilder command = new StringBuilder();
        command.append("install ");
        if (installArguments != null) {
            for (String s : installArguments) {
                command.append(s);
                command.append(" ");
            }
        }

        if (npmVersion != null) {
            command.append(npmName).append("@").append(npmVersion);
        } else {
            command.append(npmName);
        }

        try {
            node.factoryForNPMInstallation().getNpmRunner(node.proxy()).execute(command.toString());
        } catch (TaskRunnerException e) {
            log.error("Error during the installation of the NPM " + npmName + " - check log", e);
        }
    }
1133795
function npm () {

    // duplicate the generic cmd object
    const _npm = Object.create(_cmd);
    _npm.cmd = 'npm';

    // no-args
    const noargs = ['run', 'test'];
    noargs.forEach((m) => {
        Object.defineProperty(_npm, m, {
            get: function () {
                this.args.push(m);
                return this;
            }
        });
    });

    // single-arg fn
    ['prefix'].forEach((m) => {
        Object.defineProperty(_npm, m, {
            value: function (p) {
                this.args.push(`--${m}`, p);
                return this;
            }
        });

    });

    // function to use to add extra scripts
    //  npm.useScript('compile','build')
    _npm.useScript = (...scripts) => {
        scripts.forEach((m) => {
            Object.defineProperty(_npm, m, {
                get: function () {
                    this.args.push(m);
                    return this;
                }
            });
        });
    };

    return _npm;
}
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;
  }
173603
function runSimpleUpgrade (version) {
  return new Promise((resolve) => {
    let npmCommand = (version) ? `npm install -g npm@${version}` : 'npm install -g npm'
    let stdout = []
    let stderr = []
    let child

    try {
      child = spawn('powershell.exe', [ '-NoProfile', '-NoLogo', npmCommand ])
    } catch (error) {
      // This is dirty, but the best way for us to try/catch right now
      resolve({ error })
    }

    child.stdout.on('data', (data) => stdout.push(data.toString()))
    child.stderr.on('data', (data) => stderr.push(data.toString()))

    child.on('exit', () => resolve({ stderr, stdout }))

    child.stdin.end()
  })
}
1230339
function execDependencyInstall () {

	console.log('\nExecuting npm install command...');

	return new Promise(function(resolve, reject){

		var child = require('child_process').spawn('npm', ['install'], {
			cwd: process.cwd,
			detached: false,
			env: process.env,
			stdio: [process.stdin, process.stdout, process.stderr]
		});

		child.on('error', function (error) {
			console.error(colors.bold.red('ERROR: Could not install the required modules:'));
			console.error(error.stack.toString());
			process.exit(255);
		});

		child.on('close', function (exit_code) {
			if (exit_code !== 0) {
				console.error(colors.bold.red('\nERROR: npm install has been failed.'));
				process.exit(255);
			}
			console.log('\nnpm install has been completed.\n\n');
			resolve(true);
		});

	});

}
660481
function install(module, sync) {
		//  accurate enough for our purpose
		var start = Date.now(),
			arg = ['npm', ['install', module.name + '@' + module.version], {cwd: module.options.path}];

		if (!sync) {
			return childProcess.spawn.apply(childProcess.spawn, arg)
				.on('close', function(status) {
					if (status === 0) {
						module.duration = Date.now() - start;
						module.installed = true;

						wanted.emit('complete', shallow(module));
					}
					else {
						module.error = true;
						error('Failed to install: ' + module.name);
					}

					processed(module);
				});
		}

		return childProcess.spawnSync.apply(childProcess.spawn, arg);
	}
786378
function (version, verbose) {
        return __awaiter(this, void 0, void 0, function* () {
            yield mkdirp(ForestInternal.elmRoot(version));
            if (verbose) {
                console.log('FOREST: Preparing enviroment for', version.expanded);
            }
            try {
                yield runNpmCommand(version.expanded, ['init', '-y'], false);
            }
            catch (err) {
                throw new ForestError(Errors.NpmInitFailed, "npm init failed");
            }
            if (verbose) {
                console.log('FOREST: Installing...');
            }
            try {
                yield runNpmCommand(version.expanded, ['install', '--save', version.forNpm()], false);
            }
            catch (err) {
                throw new ForestError(Errors.NpmElmInstallFailed, `\`npm install ${version.forNpm()}\` failed`);
            }
            if (verbose) {
                console.log('FOREST: Finalizing...');
            }
            let binaryDir = "";
            try {
                binaryDir = yield runNpmCommand(version.expanded, ['bin'], false);
            }
            catch (err) {
                throw new ForestError(Errors.NpmBinFailed, "failed to bind elm binary");
            }
            let cachePath = path.join(ForestInternal.elmRoot(version), 'binpath.log');
            let options = { mode: 0o664 };
            let promiseFn = function (resolve, reject) {
                fs.writeFile(cachePath, binaryDir, options, (err) => {
                    if (err) {
                        throw new ForestError(Errors.BinPathWriteFailed, err.message);
                    }
                    else {
                        resolve([version, true]);
                    }
                });
            };
            return new Promise(promiseFn);
        });
    }
124935
function invokeInstall(err, result) {
    // Log the input / command parse results.
    console.log('Command-line input received:');
    console.log('package: ' + result.package);
    console.log('version: ' + result.version);
    console.log('   type: ' + (isDevDependency ? 'dev' : 'production'));
    console.log('    mvn: ' + (shouldRunMaven ? 'will run mvn' : 'will not run mvn'));

    async.map(directories,
        function (elem, callback) {
            console.log('Current element', elem);
            removeAndInstall(elem, result.package,  result.version, callback);
        },
        function (err, result) {
            if (err) {
                console.error('Something went wrong! node_modules might now be trashed, sorry.', err);
                process.exit(1);
            } else {
                const elapsed = new Date().getTime() - start;
                console.log(`Install look good! took ${elapsed}ms`);
                process.exit(0);
            }
        }
    );
}
1152597
function install(tree, options) {                                        // 37
    if (isObject(tree)) {                                                  // 38
      fileMergeContents(root, tree, options);                              // 39
      if (isFunction(onInstall)) {                                         // 40
        onInstall(rootRequire);                                            // 41
      }                                                                    // 42
    }                                                                      // 43
    return rootRequire;                                                    // 44
  }
349682
def run_npm(self):
        

        for name, version in npm_dependencies.items():
            # packages are installed globally to make sure that they are
            # installed in the virtualenv rather than the current directory.
            # it is also necessary for packages containing scripts, e.g. less
            dep_name = '%s@%s' % (name, version)
            self.run_cmd(['npm', 'install', '-g', dep_name])
50475
public function execute()
    {
        // if npm does not work, we cannot use grunt, so we return false
        $cmd = 'cd %s && npm install';
        if (IS_WIN) {
            $cmd = 'cd /d %s && npm install';
        }
        if (!$this->phpci->executeCommand($cmd, $this->directory)) {
            return false;
        }

        // build the grunt command
        $cmd = 'cd %s && ' . $this->grunt;
        if (IS_WIN) {
            $cmd = 'cd /d %s && ' . $this->grunt;
        }
        $cmd .= ' --no-color';
        $cmd .= ' --gruntfile %s';
        $cmd .= ' %s'; // the task that will be executed

        // and execute it
        return $this->phpci->executeCommand($cmd, $this->directory, $this->gruntfile, $this->task);
    }
729535
function run(argv, options, loader) {
  debug('argv', argv, 'options', options);

  if (options.help || options.h) {
    return loader.printUsage('env');
  }

  var selector = options._; // the argv, stripped of the flags (both -- and -)

  installPaths(function(er, paths) {
    var execPaths = resolvePaths(paths);

    execPaths['slc-npm'] = slcNpmPath(execPaths.slc);
    execPaths['node-npm'] = nodeNpmPath(execPaths.node);

    var env = {
      cwd: process.cwd(),
      paths: {
        link: paths,
        exec: execPaths
      },
      versions: process.versions,
      platform: process.platform,
      config: process.config,
      // redundant with .paths: execPath: process.execPath,
      features: process.features
    };
    try {
      env = selectProperties(selector, env);//XXX argv--> includes options?
    } catch (er) {
      return loader.error(er.message);
    }
    console.log(env);
  });
}
133492
function install(Vue) {
	if (install.installed) { return; }
	install.installed = true;
	Vue.component('VueFaqAccordion', component);
}
1248364
private int installGit(){
        int resultOfCommand;
        log.info("Installing git {}", new Object[]{this});
        resultOfCommand = getMachine().execCommands("install Git", ImmutableList.of("sudo apt-get -y install git"));
        if(resultOfCommand!=0)
            log.warn("Installing problem installing result {}", resultOfCommand);
        return resultOfCommand;
    }
986705
function ServerNode(opts) {

    opts = opts || {};

    /**
     * ### ServerNode.defaultConfDir
     *
     * The directory of execution of the server
     */
    this.rootDir = path.resolve(__dirname, '..');


    // Creates the http or https server (must be after rootDir is set).
    this.createServer(opts);

    /**
     * ### ServerNode.http
     *
     * The server
     */
    this.http = exp;

    /**
     * ### ServerNode.port
     *
     * Default port for server
     */
    this.port = 8080;

    /**
     * ### ServerNode.version
     *
     * The software version of the server as a string
     */
    this.version = require(path.resolve(this.rootDir, 'package.json')).version;

    /**
     * ### ServerNode.nodeGameVersion
     *
     * The official release version of nodeGame
     *
     * This includes all other modules, and it is passed by the launcher.
     *
     * Default: ServerNode.version
     */
    this.nodeGameVersion = opts.nodeGameVersion || this.version;

    /**
     * ### ServerNode.modulesVersion
     *
     * Versions of all nodegame submodules
     *
     * This includes all other modules, and it is passed by the launcher.
     *
     * Default: ServerNode.version
     */
    this.modulesVersion =
        require(path.join(this.rootDir, 'bin', 'info.js')).modulesVersion;

    /**
     * ### ServerNode.defaultConfDir
     *
     * The directory from which the default configuration files are located
     *
     * @see ServerNode.rootDir
     */
    this.defaultConfDir = path.join(this.rootDir, 'conf');

    /**
     * ### ServerNode.channels
     *
     * Object containing references to all the existing channels
     *
     * @see ServerChannel
     */
    this.channels = {};

    /**
     * ### ServerNode.defaultChannel
     *
     * The name of the default channel (will be served from '/')
     *
     * @see ServerChannel
     */
    this.defaultChannel = null;

    /**
     * ### ServerNode._defaultChannel
     *
     * The name of the default channel as specified by options
     *
     * Needs to be distinguished at load time.
     */
    this._defaultChannel = opts.defaultChannel || null;

    /**
     * ### ServerNode.rooms
     *
     * Object containing references to all existing game rooms in all channels
     *
     * @see GameRoom
     */
    this.rooms = {};

    /**
     * ### ServerNode.info
     *
     * Object containing global information about games and channels
     *
     * Games actually include also aliases.
     *
     * @see ServerNode.loadGames
     */
    this.info = {
        channels: {},
        games: {},
        aliases: {}
    };

    /**
     * ### ServerNode.defaults
     *
     * Defaults settings for the server and the channels
     *
     * Will be populated by the configure function.
     */
    this.defaults = {};

    /**
     * ### ServerNode.gamesDirs
     *
     * Array of directories that will be sequentially scanned for games
     */
    this.gamesDirs = [];

    /**
     * ### ServerNode.scannedGamesDirs
     *
     * Keeps tracks of games directories already scanned and of the outcome
     */
    this.scannedGamesDirs = {};

    /**
     * ### ServerNode.logger
     *
     * Default logger before any configuration is loaded.
     *
     * Does not print anything.
     */
    this.logger = winston;
    if (opts.logLevel) {
        if (opts.logLevel !== 'error' &&
            opts.logLevel !== 'warn' &&
            opts.logLevel !== 'info' &&
            opts.logLevel !== 'verbose' &&
            opts.logLevel !== 'debug' &&
            opts.logLevel !== 'silly') {

            throw new Error('ServerNode constructor: invalid logLevel: ' +
                            opts.logLevel);
        }
    }
    this.logger.level = opts.logLevel || 'warn';

    /**
     * ### ServerNode.debug
     *
     * If TRUE, errors will be thrown, otherwise caught and logged.
     */
    this.debug = false;

    /**
     * ### ServerNode.asyncQueue
     *
     * Object containing callbacks to be executed if no operation is in progress
     */
    this.asyncQueue = J.getQueue();

    /**
     * ### ServerNode.sio
     *
     * The Socket.IO app of the server.
     *
     * The app is shared with all the channels.
     */
    this.sio = socket_io.listen(http);

    // see http://nodejs.org/docs/latest/
    //            api/events.html#events_emitter_setmaxlisteners_n
    this.sio.sockets.setMaxListeners(0);

    /**
     * ### ServerNode.gameLoader
     *
     * Object responsible to load the games from the file system.
     */
    this.gameLoader = new GameLoader(this);

    /**
     * ### ServerNode.page
     *
     * Loading, caching of static resources and templates from file system.
     */
    this.resourceManager = new ResourceManager(this);

    /**
     * ### ServerNode.logDir
     *
     * Log directory
     */
    this.logDir = path.join(this.rootDir, 'log');

    /**
     * ### ServerNode.lastError
     *
     * Last error caught by error manager
     */
    this.lastError = null;

    /**
     * ### ServerNode.acm
     *
     * Access control from channels on servernode
     *
     * Important! Currently, acm is not enforced, all channels have access
     * to ServerNode and can modify it. Do not rely on this in production!
     *
     * @experimental
     */
    this.acm = {
        read: {},
        modify: {}
    };

    // Loading configurations.
    this.init(opts || {});
}
1052824
function execute(argv) {
  const opts = Options.parse(argv);

  if (opts.version) {
    /* eslint-disable global-require */
    console.log(`v${ require('../package.json').version }`);
    return Promise.resolve(0);
  }

  if (opts.help || !opts._.length) {
    console.log(Options.generateHelp());
    return Promise.resolve(0);
  }

  return lint(resolvePatterns(opts), opts);
}
528333
function PostInstall() {

    var self = this;

    //Initialize post installation scripts.
    var init = function() {
        self.isWin32 = ( os.platform() == 'win32' ) ? true : false;
        self.path = _( __dirname.substring(0, (__dirname.length - "script".length)-1 ) );
        self.root = process.cwd().toString();


        createVersionFile();
        //console.log('[ debug ] createVersionFile()');
        createGinaFileForPlatform();
        //console.log('[ debug ] createGinaFileForPlatform()');
    }

    var createVersionFile = function(callback) {
        var version = require( _(self.path + '/package.json') ).version;
        var target = _(self.path + '/VERSION');
        try {
            if ( fs.existsSync(target) ) {
                fs.unlinkSync(target);
                setTimeout(function(){
                    if (callback) {



                            fs.writeFileSync(target, version);
                            callback()

                    } else {
                        fs.writeFileSync(target, version);
                    }
                }, 1000)

            } else {
                fs.writeFileSync(target, version);
            }

        } catch(err) {
            throw err;
            process.exit(0)
        }
    }

    //Creating framework command line file for nix.
    var createGinaFile = function(win32Name, callback) {
        var name = require( _(self.path + '/package.json') ).name;
        var appPath = _( self.path.substring(0, (self.path.length - ("node_modules/" + name + '/').length)) );
        var source = _(self.path + '/core/template/command/gina.tpl');
        var target = _(appPath +'/'+ name);
        if ( typeof(win32Name) != 'undefined') {
            target = _(appPath +'/'+ win32Name)
        }

        //Will override.
        if ( typeof(callback) != 'undefined') {

            try {
                utils.generator.createFileFromTemplateSync(source, target);
                setTimeout(function () {
                    callback(false)
                }, 1000)
            } catch (err) {
                callback(err)
            }
        } else {
            utils.generator.createFileFromTemplateSync(source, target)
        }
    }

    var createGinaFileForPlatform = function() {
        console.log('creating platform file');
        //console.log('[ debug ] about to open ' + _(self.path + '/package.json'));
        var name = require( _(self.path + '/package.json') ).name;

        var filename = ( (self.isWin32) ? '.' : '' ) + name;

        var keepGoing = function(filename) {



            createGinaFile(filename, function onGinaFileCreated(err){

                if (err) {
                    throw err;
                    return false
                }
                // this is done to allow multiple calls of post_install.js
                var filename = _(self.path + '/SUCCESS');
                var installed = fs.existsSync( filename );
                if (!installed /**&& /node_modules\/gina/.test( new _(process.cwd()).toUnixStyle() ) */ ) {
                    fs.writeFileSync(filename, true )
                }

                // old NPM : < 3 & compatible 3+
                console.log('> now installing dependencies, please wait ...\n\r');
                var dependencies = require( _(self.path + '/package.json') ).ginaDependencies;

                // starting from NodeJS v5.x, it is done automatically
                npmInstall(dependencies);

            });
        }

        if (self.isWin32) {
            var appPath = _( self.path.substring(0, (self.path.length - ("node_modules/" + name + '/').length)) );
            var source = _(self.path + '/core/template/command/gina.bat.tpl');
            var target = _(appPath +'/'+ name + '.bat');
            if ( fs.existsSync(target) ) {
                fs.unlinkSync(target);
                // have to wait for windows to complete this
                setTimeout( function(){
                    utils.generator.createFileFromTemplateSync(source, target);
                    keepGoing(filename)
                }, 1000)
            } else {
                utils.generator.createFileFromTemplateSync(source, target);
                keepGoing(filename)
            }
        } else {
            filename += '.sh';// patch for latest npm release
            keepGoing(filename)
        }
    }


    var npmInstall = function(modules) {
        if ( modules.count() == 0 ) {
            console.log("\nGina's command line tool has been installed !\n");
            process.exit(0)
        }

        var cmd = ( isWin32() ) ? 'npm.cmd install' : 'npm install';
        var key = null;
        for (var m in modules) {
            key = m;
            if ( modules[m] != '') {
                cmd += ' '+ m +'@'+ modules[m];
                console.log('installing [ '+ m +'@'+ modules[m] +' ]');
            } else {
                cmd += ' '+ m + '@latest';
                console.log('installing [ '+ m + '@latest ]');
            }

            break
        }

        delete modules[key];

        if ( !fs.existsSync(self.path) ) {
            fs.mkdirSync(self.path)
        }

        if ( !fs.existsSync(self.path +'/node_modules') ) {
            fs.mkdirSync(self.path +'/node_modules')
        }

        if ( !fs.existsSync(self.path +'/tmp') ) {
            fs.mkdirSync(self.path +'/tmp')
        }

        //console.debug('cwd: ' + _(self.path));
        //console.debug('tmp: ' +  _(self.root +'/tmp'));

        run(cmd, { cwd: _(self.path), tmp: _(self.root +'/tmp')  })
            .onData(function(data){
                //console.info(data)
            })
            .onComplete( function done(err, data){
                if (err && err != 'false') {
                    console.error(err);
                    //console.debug('\nCommand was: \n'+ cmd)
                } //else {
                    //console.info(data);
                    //end()
                //}

                npmInstall(modules)
            })
    }

    var end = function() {
        // Update middleware file
        var filename = _(self.path) + '/MIDDLEWARE';
        var msg = "Gina's command line tool has been installed.\n\r";

        var deps = require(_(self.path) + '/package.json').dependecies;


        for (var d in deps) {
            if (d === 'express' && deps[d] != '') {
                var middleware = d +'@'+ deps[d]
            }
        }

        var expressPackage = _(self.path + '/node_modules/express/package.json');
        if ( typeof(middleware) == 'undefined' && fs.existsSync(expressPackage) ) {
            var middleware = require(expressPackage).version;
            middleware = 'express@' + middleware;
        } else if (typeof(middleware) == 'undefined') {
            throw new Error('No middleware found !!');
            process.exit(0)
        }

        if ( fs.existsSync(filename) ) { // update
            var def = fs.readFileSync(filename).toString;
            // TODO - uninstall old if installed ??
            if (def !== middleware) {

                try {

                    fs.writeFileSync(filename, middleware);
                    console.log(msg)
                } catch (err) {
                    throw new Error(err.stack||err.message||err);
                    process.exit(0)
                }

                // fs.writeFile(filename, middleware, function onWrote(err){
                //     if (err) {
                //         throw new Error(err.stack||err.message||err);
                //         process.exit(1)
                //     } else {
                //         console.log(msg)
                //     }
                // })
            } // else, nothing to do
        } else { // create

            try {

                fs.writeFileSync(filename, middleware);
                console.log(msg)
            } catch (err) {
                throw new Error(err.stack||err.message||err);
                process.exit(0)
            }

            // fs.writeFile(filename, middleware, function onWrote(err){
            //     if (err) {
            //         throw new Error(err.stack||err.message||err);
            //         process.exit(1)
            //     } else {
            //         console.log(msg)
            //     }
            // })
        }
    }

    //var createGinaHome = function() { };


    init()
}