Install dev dependencies separately
This commit is contained in:
@@ -9,7 +9,6 @@ This is a Viem and Hardhat 3 project. To get started, please read the instructio
|
|||||||
To start the lab, run:
|
To start the lab, run:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
npm install
|
|
||||||
npm run start
|
npm run start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { execSync } from 'child_process';
|
import { exec, execSync } from 'child_process';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
const execPromise = promisify(exec);
|
||||||
|
|
||||||
export function installDeps() {
|
export function installDeps() {
|
||||||
// check if node_modules exists
|
// check if node_modules exists
|
||||||
@@ -8,7 +11,30 @@ export function installDeps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// install dependencies
|
// install dependencies
|
||||||
console.log('Installing dependencies...');
|
console.log('Installing mandatory dependencies...');
|
||||||
execSync('npm install', { stdio: 'inherit' });
|
execSync('npm install --omit=dev', { stdio: 'inherit' });
|
||||||
console.log('Dependencies installed');
|
console.log('Mandatory dependencies installed');
|
||||||
|
|
||||||
|
// install dev dependencies (in the background)
|
||||||
|
console.log(); console.log(); console.log();
|
||||||
|
console.log('Installing dev dependencies...');
|
||||||
|
installDevDeps();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function installDevDeps(attempt = 1) {
|
||||||
|
try {
|
||||||
|
await execPromise('npm install', { stdio: 'inherit' });
|
||||||
|
console.log('Dev dependencies installed');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error installing dev dependencies:', error.message);
|
||||||
|
|
||||||
|
if (attempt < 3) {
|
||||||
|
const retryDelay = 5000 * attempt;
|
||||||
|
console.log(`Retrying in ${Math.round(retryDelay / 1000)} seconds...`);
|
||||||
|
setTimeout(() => installDevDeps(attempt + 1), retryDelay);
|
||||||
|
} else {
|
||||||
|
console.error('Failed to install dev dependencies.');
|
||||||
|
console.error('Please try again manually, by running "npm install" in the project directory.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user