@@ -2,7 +2,6 @@ const { execSync, spawnSync } = require('child_process');
2
2
const chalk = require ( 'chalk' ) ;
3
3
const fs = require ( 'fs-extra' ) ;
4
4
const path = require ( 'path' ) ;
5
- const removeProjectFolder = require ( './removeProjectFolder' ) ;
6
5
7
6
module . exports = packageManager => {
8
7
let package = fs . readJSONSync ( path . resolve ( 'package.json' ) ) ;
@@ -31,20 +30,29 @@ module.exports = packageManager => {
31
30
}
32
31
try {
33
32
const param =
34
- packageManager === 'yarn' ? [ 'add' , '--prefer-offline' , '--silent' ] : packageManager === 'npm' ? [ 'install' ] : [ 'add' ] ;
35
- dependencies . length > 0 &&
33
+ packageManager === 'yarn'
34
+ ? [ 'add' , '--prefer-offline' , '--silent' ]
35
+ : packageManager === 'npm'
36
+ ? [ 'install' , '--legacy-peer-deps' ]
37
+ : [ 'add' ] ;
38
+ dependencies ?. length > 0 &&
36
39
spawnSync ( packageManager , [ ...param , ...dependencies ] , {
37
40
stdio : 'inherit'
38
41
} ) ;
39
- devDependencies . length > 0 && spawnSync ( packageManager , [ ...param , '-D' , ...devDependencies ] , { stdio : 'inherit' } ) ;
40
- } catch {
41
- removeProjectFolder ( ) ;
42
- packageManager === 'yarn' &&
43
- console . log ( '\n 🛠️ If there is any cache issue, you can try running -> ' , chalk . green ( 'yarn cache clean' ) ) ;
42
+ devDependencies ?. length > 0 && spawnSync ( packageManager , [ ...param , '-D' , ...devDependencies ] , { stdio : 'inherit' } ) ;
43
+ } catch ( error ) {
44
+ console . log ( chalk . red ( '\nInstalling dependency failed with error: \n' ) ) ;
45
+ console . log ( chalk . red ( error ) ) ;
46
+
47
+ console . log ( '\n🛠️ ' + ' Possible resolution \n' ) ;
48
+
49
+ packageManager === 'yarn' && console . log ( 'If there is any cache issue, you can try running -> ' , chalk . green ( 'yarn cache clean' ) ) ;
44
50
packageManager === 'npm' &&
45
51
console . log (
46
- '\n 🛠️ If there is any peer dependency error, you can try running -> ' ,
52
+ 'If there is any peer dependency error, you can try running -> ' ,
47
53
chalk . green ( 'npm config set legacy-peer-deps true' )
48
54
) ;
55
+
56
+ throw new Error ( ) ;
49
57
}
50
58
} ;
0 commit comments