{"record":{"id":"108f2cc653ff6fad","repo":"parcel-bundler/parcel","slug":"failed-to-locate-file-originalpath","errorCode":null,"errorMessage":"failed to locate file ${originalPath}","messagePattern":"failed to locate file (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/transformers/stylus/src/StylusTransformer.js","lineNumber":194,"sourceCode":"        // checked so we invalidate the cache when they are created.\n        let restore = patchNativeFS(asset.fs, nativeGlob);\n\n        let paths = [\n          ...new Set(\n            (options.paths || []).concat(path.dirname(filepath || '.')),\n          ),\n        ];\n        found = utils.find(importedPath, paths, filepath);\n        if (!found) {\n          found = utils.lookupIndex(originalPath, paths, filepath);\n        }\n\n        for (let invalidation of restore()) {\n          asset.invalidateOnFileCreate(invalidation);\n        }\n\n        if (!found) {\n          throw new Error('failed to locate file ' + originalPath);\n        }\n      }\n\n      // Recursively process resolved files as well to get nested deps\n      for (let resolved of found) {\n        if (!seen.has(resolved)) {\n          asset.invalidateOnFileChange(resolved);\n\n          let code = await asset.fs.readFile(resolved, 'utf8');\n          for (let [path, resolvedPath] of await getDependencies(\n            code,\n            resolved,\n            asset,\n            resolve,\n            options,\n            parcelOptions,\n            nativeGlob,\n            seen,","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/transformers/stylus/src/StylusTransformer.js#L176-L212","documentation":"Thrown by @parcel/transformer-stylus when neither Parcel's resolve() nor Stylus's built-in utils.find / utils.lookupIndex can locate an @import/@require target. The resolver chain first tries Parcel's resolve with the `stylus`/`style` package conditions; if that returns nothing it falls back to Stylus's native file finder across configured paths; if both fail it throws this generic message.","triggerScenarios":"A Stylus file contains `@import 'foo'` or `@require 'foo'` where 'foo' (and 'foo.styl') does not exist in any of: the current file's directory, the configured `paths` (from .stylusrc or stylus package key), or the Stylus `include css` search paths.","commonSituations":"Typo'd import path; importing from node_modules without the right package conditions; moving a .styl file and forgetting to update relative imports; missing optional `.styl` extension handling; package not installed in node_modules.","solutions":["Confirm the file exists at the expected path relative to the importing file.","If importing from node_modules, install the package and use the bare specifier (Parcel will resolve with the stylus/style conditions).","Add the directory containing the file to `paths` in .stylusrc or in the `stylus` key of package.json.","If the path uses no extension, Stylus will try appending `.styl` — verify the basename matches exactly."],"exampleFix":"// before: src/app.styl\n@import 'theme/colors'\n// file actually lives at src/styles/colors.styl\n\n// after\n@import '../styles/colors'\n// or add to .stylusrc:\n{ \"paths\": [\"./src/styles\"] }","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction stylusImportResolves(importPath, fromFile, configPaths = []) {\n  const dir = path.dirname(fromFile);\n  const candidates = [\n    path.resolve(dir, importPath),\n    path.resolve(dir, importPath + '.styl'),\n    ...configPaths.map(p => path.resolve(p, importPath)),\n    ...configPaths.map(p => path.resolve(p, importPath + '.styl')),\n  ];\n  return candidates.find(c => fs.existsSync(c));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep shared Stylus partials under one `paths` directory declared in .stylusrc.","Use relative imports consistently to avoid ambiguity with node_modules resolution."],"tags":["stylus","css","transformer","module-resolution"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}