{"record":{"id":"a7f0c9b26c64e1b7","repo":"remix-run/remix","slug":"expected-a-file-path-or-file-url-received-f-a7f0c9","errorCode":null,"errorMessage":"Expected a file path or file:// URL, received \"${filePath}\"","messagePattern":"Expected a file path or file:// URL, received \"(.+?)\"","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/assets/src/lib/scripts/compiler.ts","lineNumber":297,"sourceCode":"      if (resolvedOptions.fingerprintAssets && parsedPathname.requestedFingerprint === null)\n        return null\n\n      return {\n        cacheControl: getFingerprintRequestCacheControl(parsedPathname.requestedFingerprint),\n        filePath,\n        isSourceMapRequest: parsedPathname.isSourceMapRequest,\n        requestedFingerprint: parsedPathname.requestedFingerprint,\n      }\n    },\n  }\n\n  function resolveInputFilePath(filePath: string): string {\n    if (filePath.startsWith('file://')) {\n      return normalizeFilePath(fileURLToPath(new URL(filePath)))\n    }\n\n    if (filePath.includes('://')) {\n      throw new TypeError(`Expected a file path or file:// URL, received \"${filePath}\"`)\n    }\n\n    return resolveFilePath(resolvedOptions.rootDir, filePath)\n  }\n\n  function invalidateScriptFileEvent(normalizedFilePath: string, event: ModuleWatchEvent): void {\n    if (isWatchIgnored(normalizedFilePath)) return\n\n    if (shouldClearResolverCacheForFileEvent(normalizedFilePath, event)) {\n      resolverFactory.clearCache()\n    }\n\n    if (isTsconfigPath(normalizedFilePath)) {\n      tsconfigTransformOptionsResolver.clear()\n      scriptStore.invalidateAll()\n      return\n    }\n","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/assets/src/lib/scripts/compiler.ts#L279-L315","documentation":"The script compiler resolves each input as either a plain file path (resolved against rootDir) or a file:// URL. Any other URL scheme (http://, https://, data:, custom://) throws because the compiler only reads local files.","triggerScenarios":"Passing 'https://cdn.example.com/app.ts' or 'http://localhost/app.ts' as a script path to the scripts compiler (resolvedModule/getPreloadLayers).","commonSituations":"Feeding dependency URLs from import maps or CDN config into the compiler; mixing remote asset URLs with local entry points; config values sourced from a manifest containing absolute URLs.","solutions":["Download/ vendor the remote script locally and reference the file path","Use a file:// URL for unusual local paths: 'file:///abs/path/app.ts'","Filter remote URLs out before passing paths to the compiler"],"exampleFix":"// before\nresolveInputFilePath('https://cdn.example.com/app.ts')\n// after\nresolveInputFilePath('app.ts') // relative to rootDir","handlingStrategy":"validation","validationCode":"function isLocal(p: string) { return !p.includes('://') || p.startsWith('file://') }\nif (!scripts.every(isLocal)) throw new Error('remote script paths not supported')","typeGuard":"function isLocalFilePath(p: string): boolean {\n  return p.startsWith('file://') || !p.includes('://')\n}","tryCatchPattern":null,"preventionTips":["Keep import-map/CDN URLs out of compiler inputs","Vendor remote scripts before build"],"tags":["scripts","compiler","url","paths","assets"],"backgroundTag":"unsupported-url-scheme","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}