Skip to content

ReferenceError: exports is not defined on NestJS project #21

@sabbirrahman

Description

@sabbirrahman

Description

In a NestJS project, the package fails at runtime with the error:

file:///demo/node_modules/.pnpm/dataforseo-client@2.0.17/node_modules/dataforseo-client/dist/cjs/index.js:2
Object.defineProperty(exports, "__esModule", { value: true });
                      ^

ReferenceError: exports is not defined
    at file:///demo/node_modules/.pnpm/dataforseo-client@2.0.17/node_modules/dataforseo-client/dist/cjs/index.js:2:23
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:400:35)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:427:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1561:24)
    at Module._compile (node:internal/modules/cjs/loader:1712:5)
    at Object..js (node:internal/modules/cjs/loader:1895:10)
    at Module.load (node:internal/modules/cjs/loader:1465:32)
    at Function._load (node:internal/modules/cjs/loader:1282:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)

Environment

  • Node.js version: 22.16
  • dataforseo-client version: 2.0.17

Steps to Reproduce

  1. Set up a new NestJS project with:
pnpm add -g @nestjs/cli
nest new demo
  1. Install dataforseo-client@2.0.17
  2. Add the following example code to the main.ts file for testing:
import { BacklinksApi } from 'dataforseo-client';
new BacklinksApi();
  1. Run the project with pnpm start:dev to see the error.

Expected Behavior

Imports should work without throwing an error.

Current Behavior

The module fails to load with an export-undefined error.

Note: The last version of dataforseo-client I'm able to use without issue is 1.0.31.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions