Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If fs.cpSync copied your framework but the destination’s symlinks still point into a cache, check the options passed to the copy: Node.js defaults dereference to false, so links are preserved rather than followed. Set dereference: true to request copies of the symlink targets. Because the Node.js version and exact call are not specified here, confirm both before treating that default as the cause.

Why the copied framework still points at the cache

fs.cpSync(src, dest[, options]) copies a directory structure and files. Its dereference option controls whether it follows symlinks; the Node.js API documents the option as “dereference symlinks. Default: false.” With the default, the destination can contain a symlink rather than a copy of the item the link targets. If that link is relative or absolute in a way that resolves into the original cache, it can continue to point there after the copy.

This explanation fits a call that omits dereference or sets it to false. The symptom alone does not establish what options were used, what the source and destination paths are, or how each link resolves. Check those details before diagnosing a particular copy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Node.js File system API documentation, v26.10.0

How to make fs.cpSync copy symlink targets

Set dereference: true in the options object. If the source is a directory tree, include recursive: true so the copy traverses it:

#1 Best Overall
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
const fs = require('node:fs');

fs.cpSync(source, destination, {
  recursive: true,
  dereference: true,
});

Use the equivalent import syntax if your project uses ES modules. The important setting for following symlinks is dereference; recursive controls recursive directory copying.

Do not confuse dereference with verbatimSymlinks

verbatimSymlinks is a different option. It controls whether path resolution for symlinks is skipped, and its documented default is false. It does not mean “copy the targets instead of the links”; use dereference: true for that request.

Rank #2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
  • Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
  • Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
  • Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
  • Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
  • From Sandisk, a brand professional photographers trust to take on assignments.

Check the call and the links when the result is unexpected

  1. Confirm the runtime: run node --version in the same environment that performs the copy. The API documents fs.cpSync as added in Node.js v16.7.0 and no longer experimental starting in v22.3.0.
  2. Inspect the literal options: verify that the executing call—not just a wrapper’s intended configuration—passes dereference: true. For directory trees, check whether recursive: true is present.
  3. Check both paths: record the source and destination layout and inspect whether each relevant symlink is relative or absolute. Determine where its target resolves from the copied location; a relative link can resolve differently when its surrounding directory changes.
  4. Reproduce with a small copy: test the same runtime and options on a minimal directory containing a symlink. This helps distinguish a configuration or path-layout issue from behavior specific to the larger framework.

If dereference: true still leaves a symlink

A report in Node.js issue #59168 describes a caller on v22.17 who saw a destination symlink despite using { dereference: true, recursive: true }. That is a version-specific reported reproduction, not proof that every v22.17 copy behaves this way or that it explains another user’s result. The available information does not establish the issue’s resolution or an affected-version range.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If your minimal reproduction behaves the same way, capture the exact Node.js version, source and destination layout, options, and link targets when investigating the report or preparing a new issue. Those details are needed to compare your result with the reported case.

Rank #3
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Module symlink flags do not change fs.cpSync

Node.js flags such as --preserve-symlinks and --preserve-symlinks-main affect module loading and module path resolution; they do not configure filesystem copying and will not make fs.cpSync dereference a link. If you also have import or dependency-resolution problems, consult the Node.js CLI documentation for the flags’ scope. It notes that loading linked native modules from more than one location can cause them to be treated as separate modules and fail to load.

Quick Recap

Bestseller No. 2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
From Sandisk, a brand professional photographers trust to take on assignments.
$188.90
SaleBestseller No. 3
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
SaleBestseller No. 4
Sandisk 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model
Sandisk 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model
IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.; POCKET-SIZED – fits easily in pockets and small bags.
$255.46
Bestseller No. 5
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$229.99
Best Value
Seagate Portable 5TB External Hard Drive HDD – USB 3.0 for PC, Mac, PS4, & Xbox - 1-Year Rescue Service (STGX5000400), Black
  • Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Rank #4
Sale
Sandisk 1TB Extreme Portable SSD, Up to 2000MB/s Transfer Speeds-New Model
  • NEARLY 2X FASTER THAN OUR PREVIOUS GENERATION(8) – move 1,000 high-res photos in under 60 seconds(6) with up to 2000MB/s transfer speeds(2).
  • IP65 RATING AND UP TO 3M DROP PROTECTION(3) – protects against spills and drops.
  • POCKET-SIZED – fits easily in pockets and small bags.
  • SPACE TO OWN YOUR AI CONTENT – speed and capacity to download your high-res clips and photo edits.
  • 256-BIT AES ENCRYPTION(4) – helps keep private files secure with password protection.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.