{"record":{"id":"a6da372107f171cf","repo":"cube-js/cube","slug":"path-abspath-replace-nodemodulespath","errorCode":null,"errorMessage":"Path '${absPath.replace(nodeModulesPath + '/', '')}' not found","messagePattern":"Path '(.+?)' not found","errorType":"exception","errorClass":"UserError","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts","lineNumber":1031,"sourceCode":"      if (this.allowNodeRequire) {\n        return null;\n      }\n      throw new UserError(`Package '${packagePath}' not found`);\n    }\n    if (fs.existsSync(absPath)) {\n      const stat = fs.lstatSync(absPath);\n      if (stat.isDirectory()) {\n        absPath = path.resolve(absPath, 'index.js');\n      }\n    }\n    // eslint-disable-next-line prefer-template\n    absPath = path.extname(absPath) !== '.js' ? absPath + '.js' : absPath;\n    if (!fs.existsSync(absPath)) {\n      if (this.allowNodeRequire) {\n        return null;\n      }\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","sourceCodeStart":1013,"sourceCodeEnd":1049,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts#L1013-L1049","documentation":"After whitelist validation the compiler appends '.js' if needed and checks that the module file exists on disk under node_modules. If it does not, and allowNodeRequire is false, it throws UserError 'Path '...' not found' naming the path relative to node_modules.","triggerScenarios":"Importing a subpath of a package that does not exist (e.g. 'lodash/deep' instead of 'lodash'), a package installed without the referenced file, or a directory lacking index.js.","commonSituations":"Package version differences where the subpath moved or was removed, deep imports into packages that only expose main entry or exports map entries, or missing devDependency in the deployment image.","solutions":["Verify the file exists: node -e \"require.resolve('<modulePath>')\" in the project root","Fix the import to a valid subpath or the package root","Install/reinstall the dependency so the referenced file exists","Enable allowNodeRequire to fall back to native require resolution"],"exampleFix":"// before\nimport { deep } from 'lodash/internal';\n\n// after\nimport { cloneDeep } from 'lodash';","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction moduleFileExists(modulePath) {\n  let p = path.resolve('node_modules', modulePath);\n  if (fs.existsSync(p) && fs.lstatSync(p).isDirectory()) p = path.join(p, 'index.js');\n  if (path.extname(p) !== '.js') p += '.js';\n  return fs.existsSync(p);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await compiler.compile();\n} catch (e) {\n  const m = String(e.message).match(/Path '(.+)' not found/);\n  if (m) console.error(`Missing module file: node_modules/${m[1]}`);\n}","preventionTips":["Avoid deep imports into package internals; use documented entry points","Pin dependency versions so subpaths do not disappear on upgrade","Verify imports with require.resolve() locally before deploying"],"tags":["module-resolution","filesystem","schema-compiler"],"backgroundTag":"module-file-not-found","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}