diff --git a/dist/setup/index.js b/dist/setup/index.js index d7fd9f84..a5ae4a27 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -71772,7 +71772,12 @@ function parseNodeVersionFile(contents) { let nodeVersion; // Try parsing the file as an NPM `package.json` // file. - nodeVersion = (_a = JSON.parse(contents).engines) === null || _a === void 0 ? void 0 : _a.node; + try { + nodeVersion = (_a = JSON.parse(contents).engines) === null || _a === void 0 ? void 0 : _a.node; + } + catch (_c) { + core.warning("Node version file is not JSON file"); + } if (!nodeVersion) { try { const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); diff --git a/src/installer.ts b/src/installer.ts index a9afb2ff..c724c6f6 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -499,7 +499,11 @@ export function parseNodeVersionFile(contents: string): string { // Try parsing the file as an NPM `package.json` // file. - nodeVersion = JSON.parse(contents).engines?.node; + try { + nodeVersion = JSON.parse(contents).engines?.node; + } catch { + core.warning("Node version file is not JSON file") + } if (!nodeVersion) { try {