PHP 8.2.30
Preview: explain-eresolve.js Size: 2.55 KB
/opt/alt/alt-nodejs19/root/lib/node_modules/npm/lib/utils/explain-eresolve.js

// 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 { 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, chalk, 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, chalk))
  }

  // 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, chalk))
  } else if (peerConflict && peerConflict.current) {
    out.push('Found: ' + explainNode(peerConflict.current, depth, chalk))
  } else if (currentEdge) {
    out.push('Found: ' + explainEdge(currentEdge, depth, chalk))
  } else /* istanbul ignore else - should always have one */ if (edge) {
    out.push('Found: ' + explainEdge(edge, depth, chalk))
  }

  out.push('\nCould not resolve dependency:\n' +
    explainEdge(edge, depth, chalk))

  if (peerConflict) {
    const heading = '\nConflicting peer dependency:'
    const pc = explainNode(peerConflict.peer, depth, chalk)
    out.push(heading + ' ' + pc)
  }

  return out.join('\n')
}

// generate a full verbose report and tell the user how to fix it
const report = (expl, chalk, noColor) => {
  const flags = [
    expl.strictPeerDeps ? '--no-strict-peer-deps' : '',
    '--force',
    '--legacy-peer-deps',
  ].filter(Boolean)

  const or = (arr) => arr.length <= 2
    ? arr.join(' or ') :
    arr.map((v, i, l) => i + 1 === l.length ? `or ${v}` : v).join(', ')

  const fix = `Fix the upstream dependency conflict, or retry
this command with ${or(flags)}
to accept an incorrect (and potentially broken) dependency resolution.`

  return {
    explanation: `${explain(expl, chalk, 4)}\n\n${fix}`,
    file: `# npm resolution error report\n\n${explain(expl, noColor, Infinity)}\n\n${fix}`,
  }
}

module.exports = {
  explain,
  report,
}

Directory Contents

Dirs: 2 × Files: 34

Name Size Perms Modified Actions
- drwxr-xr-x 2024-03-03 22:54:11
Edit Download
config DIR
- drwxr-xr-x 2024-03-03 22:54:11
Edit Download
173 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.02 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.80 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.16 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.56 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.85 KB lrwxr-xr-x 2023-12-06 18:07:50
Edit Download
1.46 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.43 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
13.53 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
6.74 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.50 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.55 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
629 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.93 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
802 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
233 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
7.03 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.68 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.04 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.44 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.09 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1.23 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
252 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
412 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
9.56 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.00 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
876 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
4.97 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
807 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
3.90 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
2.73 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
4.19 KB lrw-r--r-- 2023-12-06 18:07:50
Edit Download
1023 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download
558 B lrw-r--r-- 2023-12-06 18:07:50
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).