Skip to content

SyntaxError: The requested module 'execa' does not provide an export named 'default' when installing dependency #4655

@wojtekmaj

Description

@wojtekmaj

Describe the bug

Ignoring the fact #4575 caused vite to be falsely reported as missing, I went ahead and asked for it to be installed.

I got an error:

file:///.yarn/__virtual__/vitest-virtual-64d4633324/0/cache/vitest-npm-1.0.1-9a3034a0e7-e59bab2c0a.zip/node_modules/vitest/dist/chunks/install-pkg.ORGzQeqb.js:5
import execa from 'execa';
       ^^^^^
SyntaxError: The requested module 'execa' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async ensurePackageInstalled (file:///.yarn/__virtual__/vitest-virtual-64d4633324/0/cache/vitest-npm-1.0.1-9a3034a0e7-e59bab2c0a.zip/node_modules/vitest/dist/vendor/node.mLeBfrTn.js:84:12)
    at async startVitest (file:///.yarn/__virtual__/vitest-virtual-64d4633324/0/cache/vitest-npm-1.0.1-9a3034a0e7-e59bab2c0a.zip/node_modules/vitest/dist/vendor/node.mLeBfrTn.js:14782:8)
    at async start (file:///.yarn/__virtual__/vitest-virtual-64d4633324/0/cache/vitest-npm-1.0.1-9a3034a0e7-e59bab2c0a.zip/node_modules/vitest/dist/cli.js:134:17)

I tracked it down to a bundled version of @antfu/install-pkg version 0.1.1, which at the time was using a different, older version of execa that provided default exports. Since this dependency is bundled, it's using the same execa version vitest declares, and consequently, it errors out.

Suggested fix:
Update @antfu/install-pkg which since then has been updated not to use default export in execa.

Reproduction

  • Install vitest using Yarn PnP
  • Run vitest
  • Upon facing
     MISSING DEP  Can not find dependency 'vite'
    
    ? Do you want to install vite? › (y/N)
    
    confirm installation

System Info

  System:
    OS: macOS 14.1.1
    CPU: (8) arm64 Apple M2
    Memory: 32.31 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - /private/var/folders/3y/swkjq1x101b76mzjgt4pm2d80000gp/T/xfs-2ac5acc4/node
    Yarn: 4.0.2 - /private/var/folders/3y/swkjq1x101b76mzjgt4pm2d80000gp/T/xfs-2ac5acc4/yarn
    npm: 10.1.0 - /usr/local/bin/npm
    bun: 1.0.12 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.199
    Edge: 119.0.2151.97
    Safari: 17.1

Used Package Manager

yarn

Validations

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