How to fix npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/node_modules/package in npm
This error occurs when npm fails to create symbolic links during npm link or global package installation. Usually caused by missing directories, incorrect npm prefix configuration, or filesystem limitations.
Quick fix
Fixes npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/node_modules/package
# Check current npm prefix
npm config get prefix
# Check if lib/node_modules exists
ls -la $(npm config get prefix)/lib/node_modules
# If missing, create it
mkdir -p $(npm config get prefix)/lib/node_modules- Check and create npm prefix directories
- Fix directory ownership
- Use a custom npm prefix (recommended)
- Try npm link again
# Check current npm prefixnpm config get prefix# Check if lib/node_modules existsls -la $(npm config get prefix)/lib/node_modules# If missing, create itmkdir -p $(npm config get prefix)/lib/node_modulesnpm ERR! code ENOENTnpm ERR! syscall symlinknpm ERR! path ../lib/node_modules/package
What this error means
The ENOENT (Error NO ENTry) with "syscall symlink" means npm is trying to create a symbolic link but can't find the destination directory. This typically happens during `npm link` operations or global package installations. When you run `npm link` in a package directory, npm creates a symlink from your global node_modules to your local package. If the global npm directories don't exist or are misconfigured, this error occurs. This is especially common after upgrading Node.js or npm, when using version managers like nvm, or on filesystems that don't support symlinks (Windows shared folders, some VirtualBox configurations).
Typical symptoms
- npm link fails with 'ENOENT syscall symlink'
- Global package installation fails
- Error mentions path like '../lib/node_modules/package'
- Works with local npm install but fails with global or link
Common causes
- Global npm prefix directory doesn't exist
- The lib/node_modules directory is missing inside npm prefix
- npm prefix path is misconfigured after Node.js upgrade
- Filesystem doesn't support symlinks (Windows, VirtualBox shared folders)
- Permission issues preventing directory creation
How to fix "npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/node_modules/package"
First, verify your npm prefix and create missing directories:
# Check current npm prefix
npm config get prefix
# Check if lib/node_modules exists
ls -la $(npm config get prefix)/lib/node_modules
# If missing, create it
mkdir -p $(npm config get prefix)/lib/node_modulesEnsure you own the npm directories:
# Fix ownership (Linux/macOS)
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
# Verify you can write to it
touch $(npm config get prefix)/lib/node_modules/test && rm $(npm config get prefix)/lib/node_modules/testConfigure npm to use a directory in your home folder:
# Create a directory for global packages
mkdir -p ~/.npm-global
# Configure npm to use it
npm config set prefix ~/.npm-global
# Add to your PATH (add to ~/.bashrc or ~/.zshrc)
export PATH=~/.npm-global/bin:$PATH
# Reload shell config
source ~/.bashrcNow npm link and global installs will work without permission issues.
After fixing the directories:
# In your package directory
cd /path/to/my-package
npm link
# Then in your project
cd /path/to/my-project
npm link my-package
# Verify it worked
npm ls -g --depth=0If your filesystem doesn't support symlinks (Windows/VirtualBox):
npm install --no-bin-links
npm link --no-bin-linksThis copies files instead of creating symlinks.
Advanced notes
NVM Users: Each Node.js version has its own global npm directory. When you switch Node versions with nvm use, you may need to re-link packages.
Windows Symlinks: Windows requires admin privileges or Developer Mode to create symlinks. Run PowerShell as Administrator, or enable Developer Mode in Windows Settings.
VirtualBox Shared Folders: Enable symlinks in VM settings:
VBoxManage setextradata "VM_NAME" VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1Docker/Vagrant: Symlinks in shared/mounted folders often fail. Either:
- Install node_modules inside the container (not in shared folder)
- Use --no-bin-links
- Use a Docker named volume for node_modules
Frequently asked questions
- What does "npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/nod" mean?
- The ENOENT (Error NO ENTry) with "syscall symlink" means npm is trying to create a symbolic link but can't find the destination directory. This typically happens during npm link operations or global package installations. When you run npm link in a package directory, npm creates a symlink from your global node_modules to your local package.
- How do I fix "npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/nod"?
- This error occurs when npm fails to create symbolic links during npm link or global package installation. Usually caused by missing directories, incorrect npm prefix configuration, or filesystem limitations.
- What causes "npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/nod"?
- Global npm prefix directory doesn't exist The lib/node_modules directory is missing inside npm prefix npm prefix path is misconfigured after Node.js upgrade
- Is the "npm ERR! code ENOENT npm ERR! syscall symlink npm ERR! path ../lib/nod" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐npm Official Documentation
- ๐Docs: npm link(Official Docs)
- ๐GitHub: npm issues(GitHub)
- ๐ฌSO: npm link errors(Stack Overflow)