Skip to content

About the strange phenomenon of module loading on SMB volumes in Windows #4485

Open
@JiaJiaJiang

Description

@JiaJiaJiang

Node.js Version

v20.17.0

NPM Version

v9.8.1

Operating System

Windows 11 23H2

Subsystem

fs

Description

Hello everyone, I have encountered a strange problem and would like to ask for your help.

I have a project on an SMB volume (both the volume host and the mount end are Windows), in which some modules depend on others, so after using npm i to install the dependencies, there will be some directory links.

When I run my node program, some linked modules cannot be loaded and report the following error:
Error: EINVAL: invalid argument, readlink '/path/to/module', but this path dose exist and is accessible. I can navigate to the module directory by explorer.exe. After I access it from explorer, I start my program again, and at this time, the program can load this module normally, but the same situation will occur with other linked modules afterwards (just some of the linked modules). I can repeat the above steps until all modules are loaded by not modifying anything.

I'm not sure if this is a bug in the fs module or Windows, I have not encountered similar errors caused by SMB directory links in other programs before. I hope someone can help me analyze this strange phenomenon.

Minimal Reproduction

No response

Output

Error: EINVAL: invalid argument, readlink '/path/to/module'
    at Object.realpathSync (node:fs:2754:30)
    at toRealPath (node:internal/modules/helpers:58:13)
    at tryFile (node:internal/modules/cjs/loader:521:10)
    at tryPackage (node:internal/modules/cjs/loader:480:16)
    at Module._findPath (node:internal/modules/cjs/loader:771:18)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1211:27)
    at Module._load (node:internal/modules/cjs/loader:1051:27)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/path/to/project file) {
  errno: -4071,
  code: 'EINVAL',
  syscall: 'readlink',
  path: '/path/to/project file'
}

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask

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