Skip to content

Commit 49d93a9

Browse files
authored
Merge pull request #4676 from jzhang026/chore/error-packageJSON-filename
Given out the filename of the local projects package.json file where the error occured during rush command
2 parents 21afaae + 5eb1a2b commit 49d93a9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Provide the file path if there is an error parsing a `package.json` file.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

‎libraries/rush-lib/src/api/RushConfigurationProject.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ export class RushConfigurationProject {
245245
if (FileSystem.isNotExistError(error as Error)) {
246246
throw new Error(`Could not find package.json for ${packageName} at ${packageJsonFilename}`);
247247
}
248+
249+
// Encountered an error while loading the package.json file. Please append the error message with the corresponding file location.
250+
if (error instanceof SyntaxError) {
251+
error.message = `${error.message}\nFilename: ${packageJsonFilename}`;
252+
}
248253
throw error;
249254
}
250255

0 commit comments

Comments
 (0)