3 examples of 'npm downgrade' in JavaScript

Every line of 'npm downgrade' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
113function runSimpleUpgrade(version) {
114 return new TPromise(function (resolve) {
115 var npmCommand = version ? 'npm install -g npm@' + version : 'npm install -g npm',
116 stdout = [],
117 stderr = [],
118 child = void 0;
119
120 try {
121 child = spawn('powershell.exe', ['-NoProfile', '-NoLogo', npmCommand]);
122 } catch (error) {
123 // This is dirty, but the best way for us to try/catch right now
124 resolve({ error: error });
125 }
126
127 child.stdout.on('data', function (data) {
128 return stdout.push(data.toString());
129 });
130 child.stderr.on('data', function (data) {
131 return stderr.push(data.toString());
132 });
133
134 child.on('exit', function () {
135 return resolve({ stderr: stderr, stdout: stdout });
136 });
137
138 child.stdin.end();
139 });
140}
26installNpmPackage(name: string, version: string | null | undefined, cwd: string = this.scopes.localPath) {
27 const versionWithDelimiter = version ? `@${version}` : '';
28 const cmd = `npm i --save ${name}${versionWithDelimiter}`;
29 return this.command.runCmd(cmd, cwd);
30}
70function installVersion(version, forceInstall) {
71 return resolveVersion(version)
72 .then(function(_version) {
73 version = _version;
74 return Q.nfcall(tmp.dir.bind(tmp));
75 })
76 .spread(function(tmpDir) {
77 var options = {
78 name: 'gitbook',
79 version: version,
80 path: tmpDir,
81 forceInstall: !!forceInstall,
82 npmLoad: {
83 loglevel: 'silent',
84 loaded: false,
85 prefix: tmpDir
86 }
87 };
88 console.log('Installing GitBook', version);
89 return Q.nfcall(npmi.bind(npmi), options).thenResolve(tmpDir);
90 })
91 .then(function(tmpDir) {
92 var gitbookRoot = path.resolve(tmpDir, 'node_modules/gitbook');
93 var packageJson = fs.readJsonSync(path.resolve(gitbookRoot, 'package.json'));
94 var version = packageJson.version;
95
96 var outputFolder = path.resolve(config.VERSIONS_ROOT, version);
97
98 if (!tags.isValid(version)) throw 'Invalid GitBook version, should satisfies '+config.GITBOOK_VERSION;
99
100 // Copy to the install folder
101 return Q.nfcall(fs.copy.bind(fs), gitbookRoot, outputFolder)
102 .thenResolve(version);
103 });
104}

Related snippets