10 examples of 'npm reinstall all' in JavaScript

Every line of 'npm reinstall all' 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
128async install() {
129 let auntyVersion;
130
131 try {
132 auntyVersion = requireg('@abcnews/aunty/package.json').version;
133 } catch (ex) {
134 // Nothing
135 }
136
137 const devDependencies = [`@abcnews/aunty${auntyVersion ? `@${auntyVersion}` : ''}`];
138 const dependencies = [];
139
140 switch (this.options.template) {
141 case 'preact':
142 devDependencies.push('html-looks-like', 'preact-render-to-string');
143 dependencies.push('preact', 'preact-compat');
144 break;
145 case 'react':
146 devDependencies.push('react-test-renderer');
147 dependencies.push('react', 'react-dom');
148 break;
149 case 'vue':
150 devDependencies.push('@vue/test-utils');
151 dependencies.push('vue');
152 break;
153 default:
154 break;
155 }
156
157 const allDependencies = [].concat(devDependencies).concat(dependencies);
158 const projectDirectoryName = this.options.path.split('/').reverse()[0];
159
160 if (allDependencies.includes(projectDirectoryName)) {
161 throw new Error(
162 `npm will refuse to install a package ("${projectDirectoryName}") which matches the project directory name.`
163 );
164 }
165
166 await installDependencies(devDependencies.sort(), ['--save-dev'], this.log);
167 await installDependencies(dependencies.sort(), null, this.log);
168}
213install () {
214 this.props.providers.forEach(provider => {
215 const type = provider === 'rest' ? 'express' : provider;
216
217 this.dependencies.push(`@feathersjs/${type}`);
218
219 if (provider === 'primus') {
220 this.dependencies.push('ws');
221 }
222 });
223
224 this._packagerInstall(this.dependencies, {
225 save: true
226 });
227
228 if (this.isTypescript) {
229 const excluded = [
230 'eslint',
231 'nodemon@^1.18.7',
232 ];
233 this.devDependencies = this.devDependencies.concat([
234 '@types/compression',
235 '@types/cors',
236 '@types/helmet',
237 '@types/serve-favicon',
238 'shx',
239 'ts-node-dev',
240 'tslint',
241 'typescript',
242 `@types/${this.props.tester}`,
243 `ts-${this.props.tester}`,
244 ]).filter(item => !excluded.includes(item));
245 }
246
247 this.devDependencies.push(this.props.tester);
248
249 this._packagerInstall(this.devDependencies, {
250 saveDev: true
251 });
252}
101async install(cwd: string) {
102 const command = /^win/.test(process.platform) ? 'npm.cmd' : 'npm';
103 const args = ['install'];
104 return await spawnProcess(command, args, { cwd, stdio: 'inherit' });
105}
68function npmInstall(pkgs, location) {
69 const pkgsInstallData = [];
70
71 pkgs = _.map(pkgs, pkg => {
72 if (!pkg.type) {
73 pkg.type = 'dep';
74 }
75 if (pkg.version) {
76 pkg.name = pkg.name + '@' + pkg.version;
77 }
78 return pkg;
79 });
80
81 _.forEach(flags, (flag, key) => {
82 const pk = _.remove(pkgs, { type: key });
83 if (_.isEmpty(pk)) return;
84 pkgsInstallData.push({
85 pkgs: _.map(pk, 'name'),
86 flag
87 });
88 });
89
90 return bluebirdPromise.map(pkgsInstallData, x => {
91 return npmInstallWithFlag(x.pkgs, x.flag, location);
92 });
93
94}
180function installPackages() {
181 // cd ./output && elm-package install --yes && cd ..
182 return chdirInPromise(outputDir)
183 .then(() => { console.log(':: install Elm packages.'); })
184 .then(execInPromise('elm-package', [ 'install', '--yes' ]))
185 .then(chdirInPromise('..'));
186}
42async install() {
43 console.log('about to install', [this.nameAndVersion], process.cwd())
44 await npm.install([this.nameAndVersion], { save: true, cwd: process.cwd() })
45}
57install() {
58
59 // related to janky code above--even if we rename the files the original
60 // gradle style directories (src/main/ui/...) are still around so we need to
61 // clean up those (empty) gradle-esque directories
62 if (this.props.buildsys == 'npm') {
63 rimraf('./src/main', function (err) {
64 if (err) throw err;
65 });
66 }
67
68 this.log("Initializing the project--this may take a few minutes...");
69 if (this.props.buildsys == 'npm/yarn') {
70 if (this.props.packageManager == 'npm') {
71 this.npmInstall([],{ 'no-optional': true, "loglevel": "error" });
72 } else {
73 this.yarnInstall([],{ 'ignore-optional': true });
74 }
75 } else {
76 var done = this.async();
77 this.spawnCommand('gradle',['npmInstall']).on('close', done);
78 }
79 }
30async function forceReinstallNpmDependencies(projectPath: string):Promise {
31 rimraf.sync(`${path.normalize(projectPath)}/node_modules`);
32 rimraf.sync(`${path.normalize(projectPath)}/package-lock.json`);
33 await executeCommand(projectPath, 'npm install', true);
34}
9export function installNPMDependencies(ctx: BuildContext) {
10 return new Promise((resolve, reject) => {
11 exec(`npm install`, {
12 cwd: ctx.projectFolder,
13 }, (error, stdout) => {
14
15 if (error === null) {
16 resolve();
17 } else {
18 reject(Error(stdout));
19 }
20 });
21 });
22}
118function install(args, cb) {
119 args = ['install', '--save-dev'].concat(args);
120 utils.spawn('npm', args, {stdio: 'inherit'})
121 .on('error', cb)
122 .on('close', function(code, err) {
123 cb(err, code);
124 });
125}

Related snippets