Developer tools dump stack traces, exit codes, and jargon. Figuring out *what to do next* often means searching the same Stack Overflow answers again.
| Rule( |
| 9 | id="npm.eresolve", |
| 10 | tool="npm", |
| 11 | title="npm dependency tree conflict (ERESOLVE)", |
| 12 | why="npm could not resolve a consistent dependency tree, often due to peer dependency conflicts.", |
| 13 | checks=( |
| 14 | "Are peer dependency versions incompatible?", |
| 15 | "Is package.json pinning conflicting ranges?", |
| 16 | ), |
| 17 | fixes=( |
| 18 | "npm install --legacy-peer-deps", |
| 19 | "Or align peer dependency versions in package.json", |
| 20 | "Review the ERESOLVE report for conflicting packages", |
| 21 | ), |
| 22 | patterns=( |
| 23 | Pattern("ERESOLVE", kind="exact", required=True), |
| 24 | Pattern( |
| 25 | r"unable to resolve dependency tree|Could not resolve dependency", |
| 26 | kind="regex", |
| 27 | required=True, |
| 28 | ), |
| 29 | ), |
| 30 | confidence="high", |
| 31 | secondary=("npm", "peer"), |
| 32 | ), |
| 33 | Rule( |
| 34 | id="npm.etarget", |
| 35 | tool="npm", |
| 36 | title="npm package version not found (ETARGET)", |
| 37 | why="The requested package version does not exist in the registry.", |
| 38 | checks=( |
| 39 | "Does the version exist on npm?", |
| 40 | "Is the version range in package.json correct?", |
| 41 | ), |
| 42 | fixes=( |
| 43 | "Check available versions: npm view <package> versions", |
| 44 | "Update package.json to a published version", |
| 45 | ), |
| 46 | patterns=( |
| 47 | Pattern("ETARGET", kind="exact", required=True), |
| 48 | ), |
| 49 | confidence="high", |
| 50 | secondary=("npm", "No matching version found"), |
| 51 | ), |
| 52 | Rule( |
| 53 | id="npm.eacces", |
| 54 | tool="npm", |
| 55 | title="npm permission denied (EACCES)", |
| 56 | why="npm tried to write to a directory your user cannot modify (often a global prefix).", |
| 57 | checks=( |
| 58 | "Are you installing globally without permission?", |
| 59 | "Is the npm cache or prefix owned by root?", |
| 60 | ), |
| 61 | fixes=( |
| 62 | "Avoid sudo; fix ownership of the npm prefix", |
| 63 | "Or use a Node version manager (nvm, fnm)", |
| 64 | "For project deps: npm install (without -g)", |
| 65 | ), |
| 66 | patterns=( |
| 67 | Pattern("EACCES", kind="exact", required=True), |
| 68 | Pattern("npm", kind="tool"), |
| 69 | ), |
| 70 | confidence="high", |
| 71 | secondary=("permission denied", "EPERM"), |
| 72 | ), |
| 73 | Rule( |
| 74 | id="npm.module_not_found", |
| 75 | tool="npm", |
| 76 | title="Node module not found", |
| 77 | why="Node tried to load a package that is not installed or not resolvable from this path.", |
| 78 | checks=( |
| 79 | "Is the package listed in package.json?", |
| 80 | "Have you run npm install?", |
| 81 | "Is the import path correct?", |
| 82 | ), |
| 83 | fixes=( |
| 84 | "npm install", |
| 85 | "npm install <missing-package>", |
| 86 | ), |
| 87 | patterns=( |
| 88 | Pattern( |
| 89 | r"MODULE_NOT_FOUND|Cannot find module", |
| 90 | kind="regex", |
| 91 | required=True, |
| 92 | ), |
| 93 | ), |
| 94 | confidence="high", |
| 95 | secondary=("npm", "Error:"), |
| 96 | ), |
| 97 | Rule( |
| 98 | id="npm.err_module_not_found", |
| 99 | tool="npm", |
| 100 | title="ESM module not found (ERR_MODULE_NOT_FOUND)", |
| 101 | why="Node ESM resolution failed for an import — missing package or wrong file extension/path.", |
| 102 | checks=( |
| 103 | "Does the file or package exist?", |
| 104 | "Are you missing a .js/.mjs extension in the import?", |
| 105 | "Is \"type\": \"module\" configured as expected?", |
| 106 | ), |
| 107 | fixes=( |
| 108 | "npm install <package>", |
| 109 | "Fix the import path / extension", |
| 110 | ), |
| 111 | patterns=( |
| 112 | Pattern("ERR_MODULE_NOT_FOUND", kind="exact", required=True), |
| 113 | ), |
| 114 | confidence="high", |
| 115 | secondary=("Cannot find package", "npm"), |
| 116 | ), |
| 117 | Rule( |
| 118 | id="npm.package_not_found", |
| 119 | tool="npm", |
| 120 | title="npm package not found in registry", |
| 121 | why="The package name does not exist in the configured registry (or is private without auth).", |
| 122 | checks=( |
| 123 | "Is the package name spelled correctly?", |
| 124 | "Is it a private package requiring login?", |
| 125 | "Is the registry URL correct?", |
| 126 | ), |
| 127 | fixes=( |
| 128 | "Verify the name: npm view <package>", |
| 129 | "npm login (for private packages)", |
| 130 | ), |
| 131 | patterns=( |
| 132 | Pattern( |
| 133 | r"404 Not Found|is not in this registry|E404|" |
| 134 | r"'[^']+' is not in this registry", |
| 135 | kind="regex", |
| 136 | required=True, |
| 137 | ), |
| 138 | Pattern("npm", kind="tool"), |
| 139 | ), |
| 140 | confidence="high", |
| 141 | ), |
| 142 | Rule( |
| 143 | id="npm.peer_dependency", |
| 144 | tool="npm", |
| 145 | title="Peer dependency warning or failure", |
| 146 | why="An installed package expects a peer dependency version that is missing or incompatible.", |
| 147 | checks=( |
| 148 | "Which peer dependency is unmet?", |
| 149 | "Can you install a compatible host package version?", |
| 150 | ), |
| 151 | fixes=( |
| 152 | "npm install <peer-package>@<compatible-version>", |
| 153 | "npm install --legacy-peer-deps", |
| 154 | ), |
| 155 | patterns=( |
| 156 | Pattern( |
| 157 | r"requires a peer of|unmet peer|peer dep missing|" |
| 158 | r"ERESOLVE overriding peer dependency", |
| 159 | kind="regex", |
| 160 | required=True, |
| 161 | ), |
| 162 | ), |
| 163 | confidence="medium", |
| 164 | secondary=("npm", "peer"), |
| 165 | ), |
| 166 | Rule( |
| 167 | id="npm.enoent_package_json", |
| 168 | tool="npm", |
| 169 | title="package.json not found", |
| 170 | why="npm expected a package.json in the current directory but none was found.", |
| 171 | checks=( |
| 172 | "Are you in the project root?", |
| 173 | "Has package.json been created?", |
| 174 | ), |
| 175 | fixes=( |
| 176 | "cd into the directory that contains package.json", |
| 177 | "Or: npm init", |
| 178 | ), |
| 179 | patterns=( |
| 180 | Pattern( |
| 181 | r"ENOENT: no such file or directory.*package\.json|" |
| 182 | r"eno such package\.json|Could not read package\.json", |
| 183 | kind="regex", |
| 184 | required=True, |
| 185 | ), |
| 186 | ), |
| 187 | confidence="high", |
| 188 | secondary=("npm",), |
| 189 | ), |
| 190 | Rule( |
| 191 | id="npm.invalid_json", |
| 192 | tool="npm", |
| 193 | title="Invalid package.json", |
| 194 | why="package.json (or a lockfile) contains invalid JSON and cannot be parsed.", |
| 195 | checks=( |
| 196 | "Is there a trailing comma or syntax error in package.json?", |
| 197 | "Was the file corrupted by a merge conflict?", |
| 198 | ), |
| 199 | fixes=( |
| 200 | "Validate package.json with a JSON linter or jq", |
| 201 | "Resolve merge conflict markers if present", |
| 202 | ), |
| 203 | patterns=( |
| 204 | Pattern( |
| 205 | r"Unexpected token|JSON\.parse|Invalid package\.json|" |
| 206 | r"package\.json must be actual JSON", |
| 207 | kind="regex", |
| 208 | required=True, |
| 209 | ), |
| 210 | Pattern("npm", kind="tool"), |
| 211 | ), |
| 212 | confidence="medium", |
| 213 | ), |
| 214 | ] |