Skip to content

setup-corepack.js fails when "module" is specified in root package.json #2856

@AdaptivChris

Description

@AdaptivChris

What happened?

devbox with nodejs does not start anymore due to root package.json configuration spilling into .devbox internal working.

Steps to reproduce

  1. Create a folder
  2. Add the file package.json with {"type":"module"}
  3. Add the file devbox.json with {"include":["plugin:nodejs"]}
  4. Run devbox shell

(OS: WSL Debian)
(nodejs@24 plugin_version: 0.0.3)

Command

shell

devbox.json

{
"include": ["plugin:nodejs"]
}

Devbox version

0.17.3

Nix version

No response

What system does this bug occur on?

Other (please include in the description above)

Debug logs

✓ Computed the Devbox environment.
Starting a devbox shell...
file:///.../devboxtest/.devbox/virtenv/nodejs/bin/setup-corepack.js:12
const { execFileSync } = require("node:child_process");
                         ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/.../devboxtest/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///.../devboxtest/.devbox/virtenv/nodejs/bin/setup-corepack.js:12:26
    at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:661:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue needs triage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions