This error occurs when npm tries to create symlinks or move files across different filesystems or disk partitions. Common in Docker containers, WSL, or when node_modules is on a different drive.
The EXDEV error means npm is trying to use the `rename()` system call to move files, but the source and destination are on different filesystems or partitions. The operating system doesn't allow atomic renames across filesystem boundaries. This is extremely common in Docker containers because Docker's layered filesystem (overlay2, AUFS) treats each layer as a separate "device." It also happens in WSL when mixing Windows and Linux paths, or when your npm cache is on a different partition than your project. npm versions 4.2.2+ handle this better, but the error can still occur in certain configurations.
npm v4.2.2+ handles cross-device moves better:
npm install -g npm@latest
npm --versionThis fixes most EXDEV errors.
Keep npm operations in the same filesystem layer:
# Good: npm install and cleanup in same layer
FROM node:20
WORKDIR /app
COPY package*.json ./
RUN npm ci && npm cache clean --force
COPY . .
# Avoid: Multiple RUN commands that cross layersOr use a multi-stage build:
FROM node:20 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modulesMove your project from Windows mount to Linux filesystem:
# Instead of /mnt/c/Users/name/project
# Use the Linux home directory
cp -r /mnt/c/Users/name/project ~/project
cd ~/project
npm installThe Linux filesystem in WSL doesn't have cross-device issues.
Configure npm cache to be on the same filesystem as your project:
# Set npm cache to a directory on the same partition
npm config set cache /path/to/same/partition/.npm-cache
# Or use a project-local cache
npm install --cache ./.npm-cacheIn docker-compose, use named volumes for node_modules:
version: '3'
services:
app:
build: .
volumes:
- ./src:/app/src # Source only
- node_modules:/app/node_modules # Named volume
volumes:
node_modules:Named volumes stay on the same filesystem, avoiding EXDEV.
Why this happens in Docker: Docker's overlay filesystem stacks multiple layers. When npm tries to rename() files from one layer to another (like from cache to node_modules), it crosses a filesystem boundary. The rename() syscall can't do this atomically.
The mv workaround: The mv command handles cross-device moves by copying then deleting. Some Dockerfiles use this pattern:
RUN npm install \
&& mv ./node_modules ./node_modules.tmp \
&& mv ./node_modules.tmp ./node_modulesWindows multiple drives: If your project is on D: but Node.js is on C:, npm may fail. Keep both on the same drive.
pnpm alternative: pnpm handles this better with its content-addressable storage:
pnpm config set store-dir /app/.pnpm-storenpm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error