Skip to content

Cannot run the payload bin scripts (generate:importmap) with turborepo #14500

@Angusross111

Description

@Angusross111

Describe the Bug

The payload bin scripts dont seem to play nice with turborepo packages when used in the configs:

// apps/docs/collections/Users.ts
import { verify } from "@repo/auth/auth";
...
access: {
        read: () => {
            const test = verify();
            return test;
        },
    },
$ payload generate:importmap
/home/angus.ross/external/turborepo-payload-repro/apps/docs/collections/Users.ts:1
import { verify } from "@repo/auth/auth";
         ^

SyntaxError: The requested module '@repo/auth/auth' does not provide an export named 'verify'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:263:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)
    at async runBinScript (/home/angus.ross/external/turborepo-payload-repro/node_modules/.bun/payload@3.62.1+1734b4e7cd6dfd5c/node_modules/payload/dist/bin/index.js:88:27)
    at async bin (/home/angus.ross/external/turborepo-payload-repro/node_modules/.bun/payload@3.62.1+1734b4e7cd6dfd5c/node_modules/payload/dist/bin/index.js:45:29)
    at async start (file:///home/angus.ross/external/turborepo-payload-repro/node_modules/.bun/payload@3.62.1+1734b4e7cd6dfd5c/node_modules/payload/bin.js:30:7)

This is with

bun: 1.3.0
next: 16.0.1
payload: 3.62.1

I also tried hoisted installs but got the same error

bun install --linker hoisted

Link to the code that reproduces this issue

https://github.com/Angusross111/payload-turborepo-repro

Reproduction Steps

bun install
cd apps/docs
bun run generate:importmap

Which area(s) are affected? (Select all that apply)

area: core

Environment Info

Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  payload: 3.62.1
Operating System:
  Platform: linux
  Arch: x64
  Version: #202508231538~1758010842~22.04~85d2e57 SMP PREEMPT_DYNAMIC Tue S
  Available memory (MB): 27702
  Available CPU cores: 16

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