forked from stackblitz/bolt.new
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup-pnpm.js
More file actions
34 lines (28 loc) · 950 Bytes
/
setup-pnpm.js
File metadata and controls
34 lines (28 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { execSync } = require('child_process');
const fs = require('fs');
// check if pnpm is installed
try {
execSync('pnpm -v', { stdio: 'ignore' });
console.log('✅ pnpm is installed.');
} catch (err) {
console.error('❌ pnpm is not installed. Please install it first:');
console.error(' npm install -g pnpm');
process.exit(1);
}
// remove node_modules and package-lock.json
console.log('🧹 Cleaning up node_modules and package-lock.json...');
if (fs.existsSync('node_modules')) {
execSync('rm -rf node_modules');
}
if (fs.existsSync('package-lock.json')) {
fs.unlinkSync('package-lock.json');
}
// reinstall dependencies with pnpm
console.log('📦 Reinstalling dependencies with pnpm...');
try {
execSync('pnpm install', { stdio: 'inherit' });
console.log('🎉 Setup complete! Your project is now using pnpm.');
} catch (err) {
console.error('❌ Failed to install dependencies with pnpm.');
process.exit(1);
}