contentlayerdev / contentlayerdev/next-contentlayer-example

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

Open
#21 6 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
104
Forks
37
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.