How to use global-npm - 10 common examples

To help you get started, we’ve selected a few global-npm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kirjavascript / nibblrjr / irc / evaluate / acquire.js View on Github external
npm.load({loglevel: 'silent', lock: false}, (err, success) => {
    if (err) {
        console.error(err);
    }
    else {
        npmInstall = promisify(npm.commands.install);
        npmView = promisify(npm.commands.view);
        // disable an attack vector
        npm.config.set('ignore-scripts', true);
    }
});
github kirjavascript / nibblrjr / irc / evaluate / acquire.js View on Github external
npm.load({loglevel: 'silent', lock: false}, (err, success) => {
    if (err) {
        console.error(err);
    }
    else {
        npmInstall = promisify(npm.commands.install);
        npmView = promisify(npm.commands.view);
        // disable an attack vector
        npm.config.set('ignore-scripts', true);
    }
});
github kirjavascript / nibblrjr / irc / evaluate / acquire.js View on Github external
npm.load({loglevel: 'silent', lock: false}, (err, success) => {
    if (err) {
        console.error(err);
    }
    else {
        npmInstall = promisify(npm.commands.install);
        npmView = promisify(npm.commands.view);
        // disable an attack vector
        npm.config.set('ignore-scripts', true);
    }
});
github maxleiko / npmi / npmi.js View on Github external
callback();
                                }
                            }
                        });
                    }
                });
            }
        } else {
            if (forceInstall) {
                // reinstall package module
                if (name.indexOf('/') === -1) {
                    // not a tarball
                    npm.commands.install(installPath, [name+'@'+version], installCallback);
                } else {
                    // do not specify version for tarball
                    npm.commands.install(installPath, [name], installCallback);
                }

            } else {
                // check if package is installed
                checkInstalled(name.indexOf('/') !== -1);
            }
        }
    }
github maxleiko / npmi / npmi.js View on Github external
return function (err, view) {
            if (err) {
                // reset npm.prefix to saved value
                npm.prefix = savedPrefix;
                err.code = VIEW_ERR;
                return callback(err);
            }

            // npm view success
            var latestVersion = Object.keys(view)[0];
            if ((typeof latestVersion !== 'undefined') && (latestVersion === installedVersion)) {
                // reset npm.prefix to saved value
                npm.prefix = savedPrefix;
                return callback();
            } else {
                npm.commands.install(installPath, [name+'@'+latestVersion], installCallback);
            }
        }
    }
github maxleiko / npmi / npmi.js View on Github external
return function (err, view) {
            if (err) {
                // reset npm.prefix to saved value
                npm.prefix = savedPrefix;
                err.code = VIEW_ERR;
                return callback(err);
            }

            // npm view success
            var latestVersion = Object.keys(view)[0];
            if ((typeof latestVersion !== 'undefined') && (latestVersion === installedVersion)) {
                // reset npm.prefix to saved value
                npm.prefix = savedPrefix;
                return callback();
            } else {
                npm.commands.install(installPath, [name+'@'+latestVersion], installCallback);
            }
        }
    }
github maxleiko / npmi / npmi.js View on Github external
function loadCallback(err) {
        if (err) {
            err.code = LOAD_ERR;
            return callback(err);
        }

        // npm loaded successfully
        savedPrefix = npm.prefix; // save current npm.prefix
        npm.prefix = installPath; // change npm.prefix to given installPath
        if (!name) {
            // just want to do an "npm install" where a package.json is
            npm.commands.install(installPath, [], installCallback);

        } else if (localInstall) {
            if (forceInstall) {
                // local install won't work with version specified
                npm.commands.install(installPath, [name], installCallback);
            } else {
                // check if there is already a local install of this module
                fs.readFile(path.resolve(name, 'package.json'), 'utf8', function (err, sourcePkgData) {
                    if (err) {
                        // reset npm.prefix to saved value
                        npm.prefix = savedPrefix;
                        callback(err);
github maxleiko / npmi / npmi.js View on Github external
function installCallback(err, result) {
        // reset npm.prefix to saved value
        npm.prefix = savedPrefix;

        if (err) {
            err.code = INSTALL_ERR;
        }

        callback(err, result);
    }
github maxleiko / npmi / npmi.js View on Github external
} else {
                // check if package is installed
                checkInstalled(name.indexOf('/') !== -1);
            }
        }
    }

    npm.load(npmLoad, loadCallback);
};

npmi.LOAD_ERR    = LOAD_ERR;
npmi.INSTALL_ERR = INSTALL_ERR;
npmi.VIEW_ERR    = VIEW_ERR;

npmi.NPM_VERSION = npm.version;

module.exports = npmi;
github maxleiko / npmi / npmi.js View on Github external
if (name.indexOf('/') === -1) {
                    // not a tarball
                    npm.commands.install(installPath, [name+'@'+version], installCallback);
                } else {
                    // do not specify version for tarball
                    npm.commands.install(installPath, [name], installCallback);
                }

            } else {
                // check if package is installed
                checkInstalled(name.indexOf('/') !== -1);
            }
        }
    }

    npm.load(npmLoad, loadCallback);
};

global-npm

Require global npm as a local node module.

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis