You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add cache clearing info to JS Build config docs (#3297)
[ ] Check if this is a typo or other quick fix and ignore the rest :)
## Type of change
Update to JS build config docs
### What should this PR do?
Adds info about clearing the caches, from Angela's draft:
https://docs.google.com/document/d/13kMq9F1mUooOoLsIXN_EuAs51J8TLshw4D0-uZTK7p0/edit?tab=t.0#heading=h.pqhjvgw1gl4l
### Why are we making this change?
Reduce friction in the user experience
### What are the acceptance criteria?
Content should be clear and accurate and appear in expected location
### How should this PR be tested?
Review deploy preview
---------
Signed-off-by: s-stumbo <sally.stumbo@chainguard.dev>
* Direct access: `https://libraries.cgr.dev/javascript/`
439
+
440
+
### Apply registry changes
390
441
391
442
To apply the registry change, remove the `node_modules` directory and the
392
443
`pnpm-lock.yaml` file and run the `pnpm install` command again. This re-fetches all
393
444
packages from Chainguard and regenerates the lockfile with updated hashes.
394
445
446
+
```bash
447
+
rm -rf node_modules pnpm-lock.yaml
448
+
pnpm install
449
+
```
450
+
451
+
As an alternative to deleting the lock file, you can [run `chainctl libraries update-hashes`](#update-lockfile-hashes-1) to update hashes in place.
452
+
453
+
454
+
**Clear pnpmn caches**
455
+
456
+
pnpm has three separate layers of cached data. If you encounter stale or corrupted package data, you can clear all of these caches:
457
+
458
+
{{< details "Clear pnpm caches" >}}
459
+
460
+
**Metadata (packuments)**
461
+
462
+
There is an [experimental command](https://pnpm.io/cli/cache-delete) to delete the metadata cache:
463
+
464
+
```bash
465
+
pnpm cache delete
466
+
```
467
+
468
+
**HTTP cache**
469
+
470
+
pnpm maintains a separate HTTP cache at `~/.cache/pnpm` (or `$XDG_CACHE_HOME/pnpm` if that variable is set). Delete it with:
471
+
472
+
```bash
473
+
rm -rf "${XDG_CACHE_HOME:-$HOME/.cache}/pnpm"
474
+
```
475
+
476
+
**Content-addressable store (tarballs)**
477
+
478
+
To find and manually remove the full store:
479
+
480
+
```bash
481
+
pnpm store path
482
+
```
483
+
484
+
Then delete the directory that command outputs:
485
+
486
+
On macOS/Linux -
487
+
488
+
```bash
489
+
rm -rf "$(pnpm store path)"
490
+
```
491
+
492
+
On Windows -
493
+
494
+
Use the path returned by `pnpm store path` and delete it via File Explorer or `rmdir`.
495
+
496
+
> Note: pnpm prune removes unused tarballs but does not remove packument metadata. If you are seeing 404 errors after switching to or updating the Chainguard registry endpoint, use the commands above rather than pnpm prune.
497
+
498
+
{{< /details >}}
499
+
500
+
### Update lockfile hashes
501
+
395
502
If you are migrating an existing project and want to preserve your current
396
503
lockfile, use [`chainctl libraries update-hashes`](#updating-lockfile-hashes-for-existing-projects)
397
504
to update only the integrity hashes in place instead.
@@ -457,6 +564,8 @@ This section applies to modern versions of Yarn, also known as Yarn Berry, with
457
564
versions 2.x and higher. If you are using Yarn 1.x refer to the [Yarn Classic
458
565
section](#yarn-classic).
459
566
567
+
**Declare dependencies in package.json**
568
+
460
569
With Yarn, you declare JavaScript package dependencies in a `package.json` file
461
570
and separated into different scoped dependencies such as development and runtime
462
571
dependencies. The following block shows a minimal example with `react` and
@@ -490,6 +599,15 @@ Any dependency or dependency version changes require another install and
490
599
therefore an update to the lock file. The lock file also encodes the checksum
491
600
values in the `checksum` field.
492
601
602
+
**Direct access: Point registry to Chainguard**
603
+
604
+
To change a project to use Chainguard Libraries for JavaScript, set the registry
605
+
URL to point to Chainguard in your user `.yarnrc` file:
606
+
607
+
```bash
608
+
yarn config set npmRegistryServer https://libraries.cgr.dev/javascript/
609
+
```
610
+
493
611
### Using a repository manager
494
612
495
613
To change a project to use Chainguard Libraries for JavaScript, set the registry
@@ -510,18 +628,33 @@ more details such as authentication support.
* Direct access: `https://libraries.cgr.dev/javascript`
634
+
635
+
### Apply registry changes
516
636
517
637
To apply the registry change, run the `yarn` command again. This forces an update of
518
638
all packages from the new registry and regeneration of the lock file.
519
639
640
+
If you encounter stale or corrupted package data, clear the cache with:
641
+
642
+
```bash
643
+
yarn cache clean --all
644
+
```
645
+
646
+
If you're seeing checksum mismatch errors rather than stale data, you can control Yarn's behavior via the [`checksumBehavior` setting](https://yarnpkg.com/configuration/yarnrc#checksumBehavior) in `.yarnrc.yml`. Setting it to `reset` causes Yarn to purge and re-fetch any cache entry whose checksum doesn't match, without clearing the entire cache:
647
+
648
+
```yaml
649
+
checksumBehavior: reset
650
+
```
651
+
652
+
### Update lockfile hashes
653
+
520
654
If you are migrating an existing project and want to preserve your current
521
655
lockfile, use [`chainctl libraries update-hashes`](#updating-lockfile-hashes-for-existing-projects)
522
656
to update only the integrity hashes in place instead.
523
657
524
-
525
658
Now you can proceed with your development and testing.
526
659
527
660
<a id="yarn-berry-minimal"></a>
@@ -623,6 +756,28 @@ therefore an update to the lock file. The lock file also encodes the checksum
623
756
values in the `integrity` field and the download URL in the `resolved` field for
624
757
each module.
625
758
759
+
**Direct access: Point registry to Chainguard**
760
+
761
+
To change a project to use Chainguard Libraries for JavaScript, first export your pull token as base64-encoded environment variables:
0 commit comments