cube-js/cube · error

Typescript dependency not found. Please run this command fro

Error message

Typescript dependency not found. Please run this command from project directory.

What it means

When resolving the TypeScript compiler configuration, the container requires the local TypescriptCompiler module but cannot proceed because the TypeScript dependency is not resolvable from the current working directory. Cube expects to run from a project directory where typescript is installed. The error tells the user to run from a project directory.

Source

Thrown at packages/cubejs-server/src/server/container.ts:53

}

export class ServerContainer {
  protected isCubeConfigEmpty: boolean = true;

  public constructor(
    protected readonly configuration: { debug: boolean }
  ) {
  }

  protected getTypeScriptCompiler(): TypescriptCompilerType {
    if (packageExists('typescript', isDockerImage())) {
      // eslint-disable-next-line global-require
      const { TypescriptCompiler } = require('./typescript-compiler');

      return new TypescriptCompiler();
    }

    throw new Error(
      'Typescript dependency not found. Please run this command from project directory.'
    );
  }

  protected compareBuiltInAndUserVersions(builtInVersion: SemVer, userVersion: SemVer) {
    const compareResult = semverCompare(builtInVersion, userVersion);

    if (this.configuration.debug) {
      console.log('[runProjectDockerDiagnostics] compare', {
        builtIn: builtInVersion.raw,
        user: userVersion.raw,
        compare: compareResult,
      });
    }

    if (compareResult === -1) {
      console.log(
        `${color.yellow('warning')} You are using old Docker image (${getMajorityVersion(builtInVersion, true)}) `

View on GitHub (pinned to 7d981676b3)

Solutions

  1. cd into your project directory (the one with package.json and node_modules) and re-run the command
  2. Run `npm install typescript --save-dev` (or `yarn add -D typescript`) in the project directory
  3. Verify node_modules/typescript exists at runtime (e.g. in Docker: ensure deps installed before CMD)
  4. Use the built-in JavaScript schema mode if you do not need TypeScript

Example fix

# before
$ cubejs-server   # run from ~ or arbitrary dir

# after
$ cd /path/to/my-project
$ yarn add -D typescript
$ yarn dev
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
const path = require('path');
if (!fs.existsSync(path.join(process.cwd(), 'node_modules', 'typescript'))) {
  throw new Error('Run from project directory with typescript installed');
}

Type guard

null

Try / catch

try {
  await startServer();
} catch (e) {
  if (/Typescript dependency not found/.test(e.message)) {
    console.error('Install typescript in the project directory: yarn add -D typescript');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running a cubejs-server based app from a directory with no node_modules containing typescript (no package.json / installed deps), e.g. invoking the CLI globally from an arbitrary cwd, or typescript missing from dependencies while a .ts schema/config is used.

Common situations: Global install of cube CLI without local node_modules; Docker image built without typescript in production deps; running `cubejs-server` from a home or temp directory instead of the project root; monorepo hoisting removed typescript from the expected location.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/0cc681668d0879b7. Report an issue: GitHub.