{"record":{"id":"3574677a8e1cc261","repo":"cube-js/cube","slug":"filename-transpiling-failed","errorCode":null,"errorMessage":"'${fileName}' transpiling failed","messagePattern":"'(.+?)' transpiling failed","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts","lineNumber":1047,"sourceCode":"      }\n      // eslint-disable-next-line prefer-template\n      throw new UserError(`Path '${absPath.replace(nodeModulesPath + '/', '')}' not found`);\n    }\n    return this.readModuleFile(absPath, errorsReport);\n  }\n\n  private readModuleFile(absPath: string, errorsReport: ErrorReporter) {\n    const nodeModulesPath = path.resolve('node_modules');\n    if (!moduleFileCache[absPath]) {\n      const content = fs.readFileSync(absPath, 'utf-8');\n      // eslint-disable-next-line prefer-template\n      const fileName = absPath.replace(nodeModulesPath + '/', '');\n      const transpiled = this.transpileFile(\n        { fileName, content, isModule: true },\n        errorsReport\n      );\n      if (!transpiled) {\n        throw new UserError(`'${fileName}' transpiling failed`);\n      }\n      moduleFileCache[absPath] = transpiled; // TODO isolated transpiling\n    }\n    return moduleFileCache[absPath];\n  }\n\n  private isWhiteListedPackage(packagePath: string): boolean {\n    return packagePath.indexOf('-schema') !== -1 &&\n      (packagePath.indexOf('-schema') === packagePath.length - '-schema'.length);\n  }\n}\n","sourceCodeStart":1029,"sourceCodeEnd":1059,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts#L1029-L1059","documentation":"readModuleFile transpiles the resolved module file via transpileFile; if the transpiler returns falsy (compilation produced no output, typically due to errors captured by the ErrorReporter), UserError ''${fileName}' transpiling failed' is thrown. The fileName in the message is the path relative to node_modules.","triggerScenarios":"Importing a node_modules JS module from a data model whose content fails transpilation — syntax errors, unsupported syntax, or transpile errors reported to the ErrorReporter causing transpileFile to return null.","commonSituations":"Importing an ESM-only or TypeScript package into data models, a package shipping modern syntax unsupported by the compiler's Babel setup, or a corrupted/partial install in node_modules.","solutions":["Check the accompanying compiler error output for the underlying transpile error in the reported file","Import a build of the package with syntax the compiler supports (CommonJS/ES2015-ish dist)","Pre-bundle or transpile the dependency yourself and import the built artifact","Enable allowNodeRequire to load the module via native require instead of transpiling"],"exampleFix":"// before\nimport { x } from 'esm-only-pkg'; // ships ESM-only syntax\n\n// after\nimport { x } from 'esm-only-pkg/cjs'; // CommonJS build","handlingStrategy":"try-catch","validationCode":"const path = require('path');\nconst src = fs.readFileSync(path.resolve('node_modules', modulePath), 'utf-8');\nnew Function(src); // throws SyntaxError if the module content is unparseable","typeGuard":null,"tryCatchPattern":"try {\n  await compiler.compile();\n} catch (e) {\n  if (String(e.message).endsWith(\"' transpiling failed\")) {\n    console.error('Module failed to transpile; check its syntax/syntax-level support:', e.message);\n  }\n}","preventionTips":["Prefer packages shipping CommonJS/ES2015 dist builds","Avoid importing TypeScript or ESM-only sources from data models","Inspect the ErrorReporter output for the root transpile error"],"tags":["transpilation","schema-compiler","javascript"],"backgroundTag":"transpile-failed","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}