Skip to content

SyntaxError when running 'pnpm dev' command in the cloned repository. #21

@baydisng13

Description

@baydisng13

When running the 'pnpm dev' command in the cloned repository, the following error occurs:

- error file:///C:/Users/baydis/Desktop/code/next-contentlayer-example/node_modules/.pnpm/@effect-ts+otel@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.4.1_@opentelemetry+core@1._vak64uwhuw23bp45xj3whrz3hy/node_modules/@effect-ts/otel/_mjs/Processor/Simple/index.mjs:7
import { ConsoleSpanExporter, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
         ^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'ConsoleSpanExporter' not found. The requested module '@opentelemetry/sdk-trace-base' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@opentelemetry/sdk-trace-base';
const { ConsoleSpanExporter, SimpleSpanProcessor } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
file:///C:/Users/baydis/Desktop/code/next-contentlayer-example/node_modules/.pnpm/@effect-ts+otel@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.4.1_@opentelemetry+core@1._vak64uwhuw23bp45xj3whrz3hy/node_modules/@effect-ts/otel/_mjs/Processor/Simple/index.mjs:7
import { ConsoleSpanExporter, SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
         ^^^^^^^^^^^^^^^^^^^
SyntaxError: Named export 'ConsoleSpanExporter' not found. The requested module '@opentelemetry/sdk-trace-base' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@opentelemetry/sdk-trace-base';
const { ConsoleSpanExporter, SimpleSpanProcessor } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

This error is related to the module '@opentelemetry/sdk-trace-base' and its named exports 'ConsoleSpanExporter' and 'SimpleSpanProcessor'. The error suggests that the requested module is a CommonJS module, which may not support importing named exports. Instead, it recommends importing via the default export.

Steps to Reproduce:

  1. Clone the repository using the command: git clone https://github.com/contentlayerdev/next-contentlayer-example.git
  2. Change directory to the cloned repository: cd next-contentlayer-example
  3. Install dependencies using the package manager 'pnpm': pnpm i
  4. Run the development server: pnpm dev

Expected Behavior:
The 'pnpm dev' command should run successfully without any syntax errors.

Actual Behavior:
The 'pnpm dev' command throws a SyntaxError related to the module '@opentelemetry/sdk-trace-base' and its named exports 'ConsoleSpanExporter' and 'SimpleSpanProcessor'. The error suggests importing via the default export instead.

Additional Information:

  • The error message indicates that the issue may be caused by a compatibility problem between the CommonJS module and the import syntax used in the code.
  • It is recommended to modify the import statements for the affected modules according to the suggestions provided in the error message to resolve the issue.

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