yarnpkg/yarn · error · MessageError
linkMissing
Error message
linkMissing
What it means
Thrown in the per-package branch of 'yarn unlink' when fs.exists(linkLoc) is false for a named argument. linkLoc is path.join(config.linkFolder, name); if that symlink/folder does not exist, the package was never linked (or already unlinked), so the command aborts.
Source
Thrown at src/cli/commands/unlink.js:29
export function setFlags(commander: Object) {
commander.description('Unlink a previously created symlink for a package.');
}
export function hasWrapper(commander: Object, args: Array<string>): boolean {
return true;
}
export async function run(config: Config, reporter: Reporter, flags: Object, args: Array<string>): Promise<void> {
if (args.length) {
for (const name of args) {
const linkLoc = path.join(config.linkFolder, name);
if (await fs.exists(linkLoc)) {
await fs.unlink(path.join(await getRegistryFolder(config, name), name));
reporter.success(reporter.lang('linkDisusing', name));
reporter.info(reporter.lang('linkDisusingMessage', name));
} else {
throw new MessageError(reporter.lang('linkMissing', name));
}
}
} else {
// remove from registry
const manifest = await config.readRootManifest();
const name = manifest.name;
if (!name) {
throw new MessageError(reporter.lang('unknownPackageName'));
}
const linkLoc = path.join(config.linkFolder, name);
if (await fs.exists(linkLoc)) {
// If there is a `bin` defined in the package.json,
// link each bin to the global bin
if (manifest.bin) {
const globalBinFolder = await getGlobalBinFolder(config, flags);
for (const binName in manifest.bin) {
const binDestLoc = path.join(globalBinFolder, binName);View on GitHub (pinned to c2dda503f3)
Solutions
- Verify the name matches a package you previously linked with 'yarn link'.
- Check the link folder: inspect config.linkFolder (often ~/.config/yarn/link or the Yarn global prefix).
- If the link genuinely does not exist, no action is needed — the goal state is already reached.
- Ensure you are using the same Yarn installation/prefix that created the link.
Defensive patterns
Strategy: validation
Validate before calling
const linkLoc = path.join(config.linkFolder, name);
if (!await fs.exists(linkLoc)) {
throw new Error(`No link named "${name}" in ${config.linkFolder}; nothing to unlink.`);
} Type guard
async function linkExists(config: Config, name: string): Promise<boolean> {
return fs.exists(path.join(config.linkFolder, name));
} Prevention
- Track which packages you have linked (e.g. in a project README or script).
- Check config.linkFolder contents before unlinking.
- Make unlink idempotent in scripts by checking existence first.
When it happens
Trigger: Running 'yarn unlink <name>' where the global link folder (<linkFolder>/<name>) does not exist on disk, i.e. the source package was never registered via 'yarn link' or has already been unlinked.
Common situations: User runs 'yarn unlink foo' before ever running 'yarn link' in foo's directory; the link was already removed; the configured linkFolder points elsewhere (different prefix/global folder); typo in the name.
Related errors
- noPermission
- Don't know how to handle this file type
- unknownFolderOrTarball
- invalidPackageName
- requiredVersionInRange
AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13).
Data as JSON: /api/errors/2817c81a2cf6926e.
Report an issue: GitHub.