How does nodejs tell if it's a shortcut?

there are many shortcuts under the folder after installing with cnpm. What should I do when I use nodejs to read the files in the directory?

how can I tell if it is a shortcut?
how do I get the true direction of the shortcut?

Jul.27,2021

not much cnpm, you can put a so-called "shortcut" screenshot, I guess it should be symbolic links, if you just read and write documents, you do not need to make special treatment for symbolic links, read and write directly, the file system will help you deal with where symbolic links should be linked. If you are writing a program that needs to distinguish between symbolic links and ordinary files, you should use fs.lstat to get Stats of the target file, and then use .isSymbolicLink () to determine whether it is a symbolic link. If you want to read the absolute path of a symbolic link, use fs.readlink . For more information, please see Node.js official documents


clipboard.png

besides, you don't have to care about shortcuts. The operating system will handle the real point

.
Menu