Skip to content

[Bug] SyntaxError: Cannot use import statement outside a module (ESM issue) #1

@alih552

Description

@alih552

I attempted to run the package via npx, but it crashes immediately due to an ES Module import error. It appears the binary file is using ESM syntax (import), but Node.js is interpreting it as CommonJS because the package.json configuration is missing "type": "module".

Steps to Reproduce
Run the following command in the terminal:

npx gemini-wrapped

Actual Behavior
The CLI crashes immediately with the following stack trace:

(node:40916) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
C:\Users...\node_modules\gemini-wrapped\bin\gemini-wrapped:3
import { spawnSync } from "node:child_process";
^^^^^^

SyntaxError: Cannot use import statement outside a module
at wrapSafe (node:internal/modules/cjs/loader:1378:20)
at Module._compile (node:internal/modules/cjs/loader:1428:41)
...

Environment
OS: Windows
Node Version: v20.18.0
Command: npx gemini-wrapped

Possible Cause & Fix
The file bin/gemini-wrapped uses ES Module syntax (import), but has no file extension. Node.js treats .js or extension-less files as CommonJS by default unless configured otherwise.

Suggested Fix: Add "type": "module" to the project's package.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions