// this is called when an ERESOLVE error is caught in the exit-handler, // or when there's a log.warn('eresolve', msg, explanation), to turn it // into a human-intelligible explanation of what's wrong and how to fix. const { writeFileSync } = require('fs') const { explainEdge, explainNode, printNode } = require('./explain-dep.js') // expl is an explanation object that comes from Arborist. It looks like: // Depth is how far we want to want to descend into the object making a report. // The full report (ie, depth=Infinity) is always written to the cache folder // at ${cache}/eresolve-report.txt along with full json. const explain = (expl, color, depth) => { const { edge, dep, current, peerConflict, currentEdge } = expl const out = [] const whileInstalling = dep && dep.whileInstalling || current && current.whileInstalling || edge && edge.from && edge.from.whileInstalling if (whileInstalling) { out.push('While resolving: ' + printNode(whileInstalling, color)) } // it "should" be impossible for an ERESOLVE explanation to lack both // current and currentEdge, but better to have a less helpful error // than a crashing failure. if (current) { out.push('Found: ' + explainNode(current, depth, color)) } else if (peerConflict && peerConflict.current) { out.push('Found: ' + explainNode(peerConflict.current, depth, color)) } else if (currentEdge) { out.push('Found: ' + explainEdge(currentEdge, depth, color)) } else /* istanbul ignore else - should always have one */ if (edge) { out.push('Found: ' + explainEdge(edge, depth, color)) } out.push('\nCould not resolve dependency:\n' + explainEdge(edge, depth, color)) if (peerConflict) { const heading = '\nConflicting peer dependency:' const pc = explainNode(peerConflict.peer, depth, color) out.push(heading + ' ' + pc) } return out.join('\n') } // generate a full verbose report and tell the user how to fix it const report = (expl, color, fullReport) => { const orNoStrict = expl.strictPeerDeps ? '--no-strict-peer-deps, ' : '' const fix = `Fix the upstream dependency conflict, or retry this command with ${orNoStrict}--force, or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.` writeFileSync(fullReport, `# npm resolution error report ${new Date().toISOString()} ${explain(expl, false, Infinity)} ${fix} Raw JSON explanation object: ${JSON.stringify(expl, null, 2)} `, 'utf8') return explain(expl, color, 4) + `\n\n${fix}\n\nSee ${fullReport} for a full report.` } module.exports = { explain, report, }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
completion | Folder | 0755 |
|
|
config | Folder | 0755 |
|
|
ansi-trim.js | File | 173 B | 0644 |
|
audit-error.js | File | 978 B | 0644 |
|
cmd-list.js | File | 2.46 KB | 0644 |
|
completion.sh | File | 1.85 KB | 0755 |
|
did-you-mean.js | File | 1.46 KB | 0644 |
|
display.js | File | 2.84 KB | 0644 |
|
error-message.js | File | 12.64 KB | 0644 |
|
exit-handler.js | File | 6.77 KB | 0644 |
|
explain-dep.js | File | 3.73 KB | 0644 |
|
explain-eresolve.js | File | 2.56 KB | 0644 |
|
format-bytes.js | File | 629 B | 0644 |
|
format-search-stream.js | File | 3.93 KB | 0644 |
|
get-identity.js | File | 740 B | 0644 |
|
is-windows.js | File | 233 B | 0644 |
|
log-file.js | File | 7.64 KB | 0644 |
|
log-shim.js | File | 1.68 KB | 0644 |
|
npm-usage.js | File | 1.95 KB | 0644 |
|
open-url-prompt.js | File | 1.54 KB | 0644 |
|
open-url.js | File | 1.17 KB | 0644 |
|
otplease.js | File | 1.23 KB | 0644 |
|
ping.js | File | 252 B | 0644 |
|
pulse-till-done.js | File | 412 B | 0644 |
|
queryable.js | File | 9.58 KB | 0644 |
|
read-user-info.js | File | 1.99 KB | 0644 |
|
reify-finish.js | File | 876 B | 0644 |
|
reify-output.js | File | 4.96 KB | 0644 |
|
replace-info.js | File | 807 B | 0644 |
|
tar.js | File | 3.73 KB | 0644 |
|
timers.js | File | 3.18 KB | 0644 |
|
update-notifier.js | File | 4.45 KB | 0644 |
|
validate-lockfile.js | File | 1023 B | 0644 |
|
web-auth.js | File | 558 B | 0644 |
|