{"record":{"id":"5e5d217374c613d3","repo":"swc-project/swc","slug":"fallback-bindings-does-not-support-filesystem-acce-5e5d21","errorCode":null,"errorMessage":"Fallback bindings does not support filesystem access","messagePattern":"Fallback bindings does not support filesystem access","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/index.ts","lineNumber":253,"sourceCode":"            throw new Error(\"Bindings not found.\");\n        }\n\n        const res = await bindings.parseFile(path, toBuffer(options));\n\n        return parseProgramJson(res);\n    }\n\n    parseFileSync(\n        path: string,\n        options: ParseOptions & { isModule: false }\n    ): Script;\n    parseFileSync(path: string, options?: ParseOptions): Module;\n    parseFileSync(path: string, options?: ParseOptions): Program {\n        options = options || { syntax: \"ecmascript\" };\n        options.syntax = options.syntax || \"ecmascript\";\n\n        if (!bindings && !!fallbackBindings) {\n            throw new Error(\n                \"Fallback bindings does not support filesystem access\"\n            );\n        } else if (!bindings) {\n            throw new Error(\"Bindings not found.\");\n        }\n\n        return parseProgramJson(bindings.parseFileSync(path, toBuffer(options)));\n    }\n\n    /**\n     * Note: this method should be invoked on the compiler instance used\n     *  for `parse()` / `parseSync()`.\n     */\n    async print(m: Program, options?: Options): Promise<Output> {\n        options = options || {};\n\n        if (bindings) {\n            return bindings.print(stringifyProgram(m), toBuffer(options));","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/packages/core/src/index.ts#L235-L271","documentation":"Compiler.parseFileSync() is synchronous and reads the file from disk inside the native binding. When the native binding did not load but the @swc/wasm fallback is present, it throws 'Fallback bindings does not support filesystem access' (note: this message variant has no trailing period) because the fallback intentionally does no filesystem I/O. Your process is running on @swc/wasm and called a native-only, file-based API.","triggerScenarios":"`compiler.parseFileSync(path, opts)` when require('./binding.js') failed and @swc/wasm was loaded — missing platform package, invalid SWC_BINARY_PATH, or a runtime where native addons can't load.","commonSituations":"Synchronous codemod/CLI paths in containers with pruned optional packages; sandboxed runtimes rejecting native modules; postinstall failures silently switching the engine to WASM.","solutions":["Repair the native install (clean reinstall with optional platform packages) — the sync file API only exists natively","If staying on the fallback, read the file yourself and call the content-based API: `compiler.parseSync(fs.readFileSync(path, 'utf8'), opts)` (parse itself still needs native bindings for AST output)","Validate or unset SWC_BINARY_PATH","Pin the platform package as an explicit optionalDependency so it isn't skipped"],"exampleFix":"// before\nconst ast = compiler.parseFileSync(path);\n\n// after: read in JS, parse the contents (native bindings still required for parse)\nconst ast = compiler.parseSync(require('fs').readFileSync(path, 'utf8'));","handlingStrategy":"validation","validationCode":"const { Compiler } = require('@swc/core');\nfunction canUseFileSyncApis() {\n  try {\n    new Compiler().parseSync(''); // native-only probe\n    return true;\n  } catch (e) {\n    if (e instanceof Error && /does not support this interface|Bindings not found|filesystem access/.test(e.message)) {\n      return false;\n    }\n    throw e;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const ast = compiler.parseFileSync(path, opts);\n} catch (e) {\n  if (e instanceof Error && /Fallback bindings does not support filesystem access/.test(e.message)) {\n    // WASM fallback active: read the file yourself, then call the content-based API\n    const src = require('fs').readFileSync(path, 'utf8');\n  }\n  throw e;\n}","preventionTips":["Check for native bindings before sync file-based SWC calls; they only exist in native mode","Use content-based APIs in environments that may run the WASM fallback","Fix installs so native bindings load instead of permanently working around the fallback"],"tags":["swc","wasm-fallback","parsefilesync","filesystem","native-bindings"],"backgroundTag":"wasm-fallback-limitations","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}