Instructions for the fs.symlink method in node.js

  • 2020-05-05 10:55:39
  • OfStack

method description:

Create symbolic links.


fs.symlink(srcpath, dstpath, [type], [callback(err)])

Since this method belongs to the fs module, it is necessary to introduce the fs module (var fs= require(" fs "))

before using it

receive parameters:

srcpath                           is the path to the source directory or file


type                             default: 'file', optional values' dir', 'file', or' junction', which is only used for Windows (ignored on other platforms).

Note that the directory to be converted from Windows node is the absolute path. When "junction" is used, the target parameter will be automatically normalized to the absolute path.

The callback                   callback passes an exception parameter err

source code:

fs.symlink = function(destination, path, type_, callback) {
  var type = (util.isString(type_) ? type_ : null);
  var callback = makeCallback(arguments[arguments.length - 1]);
  if (!nullCheck(destination, callback)) return;
  if (!nullCheck(path, callback)) return;
  binding.symlink(preprocessSymlinkDestination(destination, type),

Related articles: