Skip to main content
JavaScript is a high-level, interpreted programming language primarily used for creating interactive and dynamic web content widely used by developers. Endor Labs supports the scanning and monitoring of JavaScript projects. Using Endor Labs, application security engineers and developers can:
  • Scan their software for potential security issues and violations of organizational policy.
  • Prioritize vulnerabilities in the context of their applications.
  • Understand the relationships between software components in their applications.

System specifications for deep scan

Before you proceed to run a deep scan, ensure that your system meets the following specification.

Software prerequisites

  • Install the following software before you scan:
    • Yarn: Any version
    • npm: 6.14.18 or higher versions
    • pnpm: 3.0.0 or higher versions
    • Rush: 5.90.0 or higher versions. To enable Rush support, set the environment variable ENDOR_RUSH_ENABLED=true.
  • Install Bazel version 5.x.x, 6.x.x, 7.x.x, 8.x.x, or 9.x.x if your project uses Bazel. Endor Labs supports Bzlmod with Bazel aspects. See Bazel for more information.
  • Make sure your repository includes one or more files with .js or .ts extension.
To run deep scanning for JavaScript and TypeScript projects make sure you have the following prerequisites installed:
  • Install endorctl version 1.7.0 or higher.
  • Install Node.js version 4.2.6 or higher to support the required TypeScript version.
  • Install a TypeScript version greater than 4.9 and up to 6.X.X.
  • Install tsserver. TypeScript includes tsserver, so installing the right TypeScript version also installs tsserver. Install the appropriate TypeScript version based on your Node.js version.
  • Use the following command based on your Node.js version to install typescript:
  • Run the following command to verify the tsserver installation
    If you are running the endorctl scan with --install-build-tools, you don’t need to install tsserver. See Configure build tools for more information.

Build JavaScript projects

You can build your JavaScript projects before running a scan. Building first creates a package-lock.json, yarn.lock, or pnpm-lock.yaml file, which speeds up the scan. Ensure your repository has package.json and run the following command making sure it builds the project successfully.
If the project is not built, endorctl builds the project during the scan and generates package-lock.json, yarn.lock, or pnpm-lock.yaml file. Make sure that npm, Yarn, or pnpm is available on your system. If your repository includes a lock file, endorctl uses the existing file for dependency resolution and does not create it again. When endorctl installs dependencies during a scan, it suppresses package lifecycle scripts across npm, Yarn Classic, Yarn Berry, pnpm, and Rush so install hooks don’t execute arbitrary code. For Yarn projects, endorctl detects the Yarn version from the yarn.lock format before checking the installed yarn binary. For Yarn Berry projects, endorctl sets nodeLinker: node-modules in a temporary backup of .yarnrc.yml for dependency and call graph analysis and restores your original .yarnrc.yml after the scan. During hosted SCM app scans, endorctl also clears yarnPath in that temporary .yarnrc.yml so the scan uses the provisioned Yarn toolchain. The npm install command may fail in a subdirectory if your project has a package-lock.json file at the root of the repository but not in sub-packages. See the following example.
You need to instruct endorctl to use the root-level lock file to avoid scan failures in monorepo setups where dependencies are centrally managed at the root. Set the following environment variable before you run the scan.

Specify a custom lock file location

Use ENDOR_JS_LOCK_FILE_PATH to specify the exact lock file for endorctl to use during a scan. This is useful when the lock file doesn’t live in the package directory or the repository root, for example, in monorepos, nested projects, or custom build setups. The variable applies to npm, Yarn, pnpm, and Rush projects.
ENDOR_JS_LOCK_FILE_PATH takes precedence over ENDOR_JS_USE_ROOT_DIR_LOCK_FILE and over the default package-directory and workspace-root discovery logic.
The value can be a path relative to the repository root or an absolute path. The basename must be one of package-lock.json, npm-shrinkwrap.json, yarn.lock, or pnpm-lock.yaml.
You can set only one lock file path at a time. For monorepos with multiple package managers or lock files, run separate scans and set the variable to the appropriate lock file for each scan.
If the file is missing or the basename doesn’t match the detected package manager, endorctl logs a warning and falls back to the default lock file discovery.

Scan Rush monorepos

Rush is a monorepo management tool for JavaScript/TypeScript that works on top of npm, pnpm, or Yarn and manages multiple projects in a single repository using a centralized configuration. Endor Labs detects Rush repositories using the rush.json file at the repository root and scans them with the standard JavaScript workflow. Endor Labs infers the package manager and uses the corresponding lock file for dependency resolution. Run the following command at the repository root to build the repository before a scan and to ensure the appropriate lock file exists.
To scan Rush monorepos, you must first enable Rush detection.
Run endorctl scan to discover Rush dependencies.

Configure call graph generation timeout

When generating call graphs for JavaScript/TypeScript projects, endorctl uses tsserver to analyze the code. By default, tsserver waits 15 seconds for a response before timing out. For large or complex projects, you may need to increase this timeout. Set the ENDOR_JS_TSSERVER_TIMEOUT environment variable to specify the timeout in seconds.
Increasing the timeout might be beneficial in the following scenarios:
  • Large monorepos with many TypeScript files
  • Projects with complex type hierarchies
  • Projects with extensive type checking requirements

Override JavaScript package manager detection

endorctl detects the JavaScript package manager automatically. You can override this detection by setting the ENDOR_JS_PACKAGE_MANAGER environment variable to npm, yarn, pnpm, or lerna. For example, to use npm as the package manager run the following command.
This setting forces endorctl to use the specified package manager and overrides all other JavaScript package manager configuration variables.

Scan Bazel projects

Endor Labs supports Bazel scans for JavaScript and TypeScript with Bazel aspects. See Bazel for build instructions, supported rules, and scan commands. See Bazel Aspects for more information.
  • rules_js (>= 2.0.0): scan targets such as js_binary and js_library. Supports Bzlmod. Pass --use-bazel-aspects.
  • rules_ts (>= 1.0.0): scan targets such as ts_project and ts_project_rule. Supports both the WORKSPACE model and Bzlmod. Pass --use-bazel-aspects.

Scan TypeScript projects with rules_ts

Ensure that the following prerequisites are in place:
  • A Bazel workspace (WORKSPACE or MODULE.bazel)
  • rules_ts >= 1.0.0 in your workspace
  • endorctl with --use-bazel-aspects
Run the following command to discover TypeScript targets.
Run the following command to scan those targets.
For call graph generation on TypeScript sources, endorctl uses tsserver. Large repositories may need a higher timeout. See Configure call graph generation timeout.

Run a scan

Perform a scan to get visibility into your software composition and resolve dependencies.

Understand the scan process

Dependency analysis tools analyze the lock file of an npm, Yarn, pnpm, or Rush package and resolve its dependencies. For each direct and transitive dependency in a lock file, Endor Labs records both the resolved version and the declared version range, and marks lock-resolved dependencies as locked. To resolve dependencies from private repositories, Endor Labs reads the .npmrc and .yarnrc.yml settings from the repository and your configured package manager integrations. Endor Labs goes beyond manifest analysis by inspecting source imports across your JavaScript and TypeScript files to identify:
  • Dependencies listed in the manifest file but not used by the application
  • Dependencies used by the application but not listed in the manifest file
  • Dependencies listed in the manifest as transitive but used directly by the application
  • Dependencies categorized as test in the manifest, but used directly by the application
This import analysis reduces false positives and identifies test dependencies used in production code. Endor Labs tags imported packages as Phantom and reports them as unpinned when the importing package doesn’t declare them in its package.json. Declaration checks cover dependencies, devDependencies, optionalDependencies, peerDependencies, and peerDependenciesMeta. Root-declared imports take their pinned status from the root package.json version specification. If node_modules holds a stale nested copy of a package, Endor Labs redirects the import to the version recorded in the lock file. Endor Labs logs an aggregated diagnostic summary of call graph and phantom dependency analysis per package, and logs partial import scans at the info level. Endor Labs also supports npm, Yarn, pnpm, and Rush workspaces. When your packages use workspaces, Endor Labs resolves dependencies from the workspace configuration so each package builds consistently. The lock file speeds up the scan when it exists in the repository. endorctl skips the build step and uses the existing files for analysis.

Configure private npm package repositories

Endor Labs supports fetching and scanning dependencies from private npm and Yarn package registries, including generating call graphs for private direct and transitive dependencies. During call graph analysis, Endor Labs authenticates to your configured registries using Bearer or Basic credentials, installs any required transitive private packages, and reuses existing local node_modules copies when available. See npm package manager integrations to configure private registries.

Known Limitations

  • Endor Labs doesn’t currently support local package references
  • If a dependency cannot resolve from the lock file, building that specific package may fail. The package may no longer exist in npm, or the .npmrc file may not be properly configured. Other packages in the workspace are scanned as usual.

Call graph limitations

  • The call graph might not include functions passed as arguments to call expressions.
  • The call graph might not include functions that return and then execute.
  • The call graph might not include functions assigned to a variable based on a runtime value.
  • The call graph might not include functions assigned to an array element.

Troubleshoot errors

  • Unresolved dependency errors: The manifest file package.json is not buildable. Run npm install, yarn install, pnpm install, or rush install in the root project to debug this error. For pnpm projects, scan logs include the sanitized pnpm install error output when installation fails.
  • Incomplete node_modules during call graph generation: Call graph generation fails with unable to generate callgraph for '<package>' because dependencies were not downloaded when resolved dependencies exist without a corresponding node_modules directory. Install dependencies before running a deep scan or allow endorctl to download them with valid registry credentials.
  • Resolved dependency errors: A dependency version does not exist, or Endor Labs can’t find it. The package may no longer exist in the repository.
  • Registry connection errors: Recent Node.js releases, including Node.js 22, refuse registries and proxies that only offer TLS 1.0 or 1.1 or use SHA-1 signed certificate chains. Upgrade the registry or proxy to TLS 1.2 or later with a certificate chain signed with SHA-256 or stronger.
  • Rush install fails with pnpm 6: pnpm 6 can’t fetch packages on Node.js 20 or later, so the Rush install fails and the scan loses reachability data. Findings still come from the Rush lock file. Set rushVersion to 5.100.2 or later and pnpmVersion to 7.33.7 or later in rush.json, run rush update, and commit the changes.
  • Re-created findings: npm projects without a committed lock file that requested Node.js 14 or earlier now resolve with npm 10. npm 10 records git, file:, and tarball dependencies under different identifiers, for example by version instead of by commit. Endor Labs deletes the old findings for those dependencies and creates new ones, so snoozes, tags, and annotations on them don’t carry over.