diff --git a/lib/internal/v8_prof_polyfill.js b/lib/internal/v8_prof_polyfill.js index 59e1b8947eed55..7d8d3ff0202d20 100644 --- a/lib/internal/v8_prof_polyfill.js +++ b/lib/internal/v8_prof_polyfill.js @@ -48,8 +48,15 @@ const os = { } let out = cp.spawnSync(name, args).stdout.toString(); // Auto c++filt names, but not [iItT] - if (process.platform === 'darwin' && name === 'nm') + if (process.platform === 'darwin' && name === 'nm') { + // nm prints an error along the lines of "Run xcodebuild -license" and + // exits when Xcode hasn't been properly installed or when its license + // hasn't been accepted yet. Basically any mention of xcodebuild in + // the output means the nm command is non-functional. + const match = out.match(/(?:^|\n)([^\n]*xcodebuild[^\n]*)(?:\n|$)/); + if (match) throw new Error(match[1]); out = macCppfiltNm(out); + } return out; } };