Skip to content

Flattening feature creates lengthy folder structures #6830

@ishpagin

Description

@ishpagin

Hello pnpm team,

I'm having an issue on Windows because of the long path names that pnpm is creating. I believe this is due to the flattening feature that creates quite lengthy folder structures. Unfortunatly, this is causing problems when I'm trying to build my project, since Windows has a limit of 260 characters for the path.

For example, I have a package @nuxtjs+eslint-config@10.0.0_@typescript-eslint+parser@5.62.0_eslint-import-resolver-typescript@2.7.1_eslint@8.15.0. As a result, I have very long path when I try build the project C:/Users/YourName/Documents/Projects/YourProject/node_modules/@nuxtjs+eslint-config@10.0.0_@typescript-eslint+parser@5.62.0_eslint-import-resolver-typescript@2.7.1_eslint@8.15.0/some/other/directory/with/many/subdirectories/and/a/very/long/path.js, the build process can't find the files because the path is too long.

I've already tried several workarounds such as enabling long paths in Windows and moving my project closer to the root directory, but these haven't solved my problem completely.

This is not a bug of the @nuxtjs package. It occurs in our internal repositories that use the layers mechanism from Nuxt 3 and create very long paths when we want to import a file from a layer below. But this could be repeated for any deeply nested repository. For example, C:/Users/YourName/Documents/Projects/Some-Long-Path-To-Cause-An-Error-With-Pnpm-Resolution/YourProject/node_modules/@nuxtjs+eslint-config@10.0.0_@typescript-eslint+parser@5.62.0_eslint-import-resolver-typescript@2.7.1_eslint@8.15.0/index.js. The only fix that helped me was setting the node-linker=hoisted variable to avoid creating long paths. Could you perhaps make the hashing shorter, for example, to avoid generating such long results when flattening?

Could you please look into this issue and perhaps consider a way to reduce the length of the path names created by pnpm? This would help a lot for those of us who are using Windows for development, but I read that Linux also has a problem that is not written anywhere how to solve.

Thank you for your time and for developing such a helpful tool!

Best regards,

pnpm version:

pnpm -v
8.5.1/latest

Code to reproduce the issue:

{
  "dependencies": {
    "nuxt": "^3.6.3",
    "@nuxt/types": "2.15.8",
    "@nuxt/typescript-build": "2.1.0",
    "@nuxtjs/eslint-config-typescript": "10.0.0",
    "eslint": "8.15.0"
  }
}

shamefully-hoist=true

import file from path with loooong name, or multiple pathes and from folder @nuxtjs+eslint-config@10.0.0_@typescript-eslint+parser@5.62.0_eslint-import-resolver-typescript@2.7.1_eslint@8.15.0

Expected behavior:

No errors

Actual behavior:

ERROR Error: ENOENT: no such file or directory, realpath

Additional information:

  • node -v prints:
    node -v
    v18.16.1

  • Windows, macOS, or Linux?:
    Windows 10/11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions