Skip to content

Fail to patch lock while when a dependency is depending on a different version of Next.js #65182

@mwskwong

Description

@mwskwong

Link to the code that reproduces this issue

https://github.com/mwskwong/next-patch-lockfile-fail

To Reproduce

Run next dev or next build and observe the terminal output.

Current vs. Expected behavior

Current

Dependencies are as follow:

├── next@14.3.0-canary.31
└─┬ react-email@2.1.2
  └── next@14.1.0

Next.js is trying to patch the lock file for the Next.js v14.1.0. It failed to do so, and threw the following error:

 ⚠ Found lockfile missing swc dependencies, patching...
 ⨯ Failed to patch lockfile, please try uninstalling and reinstalling next in this workspace
TypeError: Cannot read properties of undefined (reading 'os')
    at fetchPkgInfo (/node_modules/next/dist/lib/patch-incorrect-lockfile.js:73:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async patchIncorrectLockfile (/node_modules/next/dist/lib/patch-incorrect-lockfile.js:162:26)

Expected

Such error should not be thrown

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: 1.22.19
  pnpm: 8.15.4
Relevant Packages:
  next: 14.3.0-canary.31 // Latest available version is detected (14.3.0-canary.31).
  eslint-config-next: 14.3.0-canary.31
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

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

create-next-app

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

next dev (local), next build (local)

Additional context

So far, this doesn't seem to impact the main application, including next dev and next build.

There isn't seem to have any issues on starting the React Email dev server, which is based on Next.js either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.create-next-appRelated to our CLI tool for quickly starting a new Next.js application.locked

    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