Skip to content

statSync fails in detecting link #47633

@FStefanni

Description

@FStefanni

Version

v18.15.0

Platform

Linux debian 6.1.0-7-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.20-2 (2023-04-08) x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Just call statSync() on node_modules/.bin/mocha:

import fs from "node:fs"

const mocha = "<abs path>/node_modules/.bin/mocha";
const stat = fs.statSync(mocha);
console.log(`File: ${stat.isFile()}, Link: ${stat.isSymbolicLink()}`);

Result:

File: true, Link: false

But if I run in bash:

ls -l <abs path>/node_modules/.bin/mocha
stat <abs path>/node_modules/.bin/mocha

Result:

lrwxrwxrwx 1 user group 21 20 apr 08.33 <abs path>/node_modules/.bin/mocha -> ../mocha/bin/mocha.js

File: <abs path>/node_modules/.bin/mocha -> ../mocha/bin/mocha.js
Size: 21        	Blocks: 0          IO Block: 4096   symbolic link
Device: 259,2	Inode: 14118017    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/   user)   Gid: ( 1000/   group)
Access: 2023-04-20 08:54:29.337525872 +0200
Modify: 2023-04-20 08:33:01.270951671 +0200
Change: 2023-04-20 08:33:01.270951671 +0200
 Birth: 2023-04-20 08:33:01.270951671 +0200

So it is truly a symbolic link.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

it should say that it is a link and not a regular file

What do you see instead?

It says it is a regular file

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.fsIssues and PRs related to the fs subsystem / file system.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions