Search code examples
next.jsvercelpnpm

ERROR Symlink path is the same as the target path (/vercel/path0/node_modules/next)


I got this on Vercel when deploying after changing my repo name in an app using the pnpm package manager.

Running build in Cleveland, USA (East) – cle1
Cloning github.com/myorg/myrepo (Branch: mybranch, Commit: 8dd529e)
Skipping build cache, deployment was triggered without cache.
Cloning completed: 1.683s
Running "vercel build"
Vercel CLI 31.2.3
Detected `pnpm-lock.yaml` version 6 generated by pnpm 8...
Installing dependencies...
Lockfile is up to date, resolution step is skipped
Progress: resolved 1, reused 0, downloaded 0, added 0
Packages: +1073
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /vercel/.local/share/pnpm/store/v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 1073, reused 0, downloaded 32, added 32
Progress: resolved 1073, reused 0, downloaded 120, added 119
Progress: resolved 1073, reused 0, downloaded 277, added 277
Progress: resolved 1073, reused 0, downloaded 361, added 360
Progress: resolved 1073, reused 0, downloaded 481, added 477
Progress: resolved 1073, reused 0, downloaded 631, added 628
Progress: resolved 1073, reused 0, downloaded 722, added 717
Progress: resolved 1073, reused 0, downloaded 849, added 847
Progress: resolved 1073, reused 0, downloaded 945, added 943
Progress: resolved 1073, reused 0, downloaded 1024, added 1020
Progress: resolved 1073, reused 0, downloaded 1068, added 1068
Progress: resolved 1073, reused 0, downloaded 1071, added 1070
Progress: resolved 1073, reused 0, downloaded 1072, added 1071
Progress: resolved 1073, reused 0, downloaded 1073, added 1073, done
 ERROR  Symlink path is the same as the target path (/vercel/path0/node_modules/next)
pnpm: Symlink path is the same as the target path (/vercel/path0/node_modules/next)
    at symlinkDir (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:101313:15)
    at symlinkDirectRootDependency (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:135270:58)
    at async /pnpm8/node_modules/pnpm/dist/pnpm.cjs:183785:11
    at async Promise.all (index 76)
    at async linkDirectDepsOfProject (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:183783:7)
    at async Promise.all (index 0)
    at async linkDirectDeps (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:183723:34)
    at async headlessInstall (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:184134:26)
    at async _install (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:190692:33)
    at async mutateModules (/pnpm8/node_modules/pnpm/dist/pnpm.cjs:190559:23)
Error: Command "pnpm install" exited with 1

What did I do wrong, how do I fix this? What is this error even saying, and why might it happen?


Solution

  • I got the same error when testing some local libraries. In my package.json I was importing the lib with:

    "<name-of-your-lib>": "link:../"
    

    If you have something similar, make sure the path is right, in my case the library is in the above folder, so ../

    1. Delete pnpm-lock.yaml
    2. Delete the node_modules
    3. Run pnpm install again

    (In my case I had to change the link path to a wrong one "../../", install, and then go back to the right one and install again, by some magic it worked)

    To find out if you have any links, run:

    npm ls -g --depth=0 --link=true
    

    If you have it, you can use the

    npm unlink
    

    https://dev.to/erinbush/npm-linking-and-unlinking-2h1g