Skip to content

Commit 29a9513

Browse files
victorboissierefilipesilva
authored andcommitted
fix(@angular/cli): add error message when missing config env variable (#5980)
I tried to implement a continuous integration system on my VPS. I have a PHP script that runs ng build. However in my default PHP configuration no environment variable HOME or USERPROFILE was set. I had this error : `Path must be a string. Received undefined`. I had to take some time to see where the problem came from so I made a pull request to clarify the error. Now it is : `Error: Missing environment variable HOME` which does not require to look at the code. This message would have saved me some time.
1 parent f502bd9 commit 29a9513

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/@angular/cli/models/config.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ const CLI_CONFIG_FILE_NAME_ALT = 'angular-cli.json';
1313

1414

1515
function getUserHome() {
16-
return process.env[(process.platform.startsWith('win')) ? 'USERPROFILE' : 'HOME'];
16+
const envHomeName = (process.platform.startsWith('win')) ? 'USERPROFILE' : 'HOME';
17+
const env = process.env[envHomeName];
18+
if (env == null) {
19+
throw new Error('Missing environment variable ' + envHomeName);
20+
}
21+
return env;
1722
}
1823

1924

0 commit comments

Comments
 (0)