docker-node-version-compat-modules
Resolves Node.js version mismatches when mounting host node_modules into Docker containers.
Install
mkdir -p .claude/skills/docker-node-version-compat-modules && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/12266" && unzip -o skill.zip -d .claude/skills/docker-node-version-compat-modules && rm skill.zipInstalls to .claude/skills/docker-node-version-compat-modules
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Fix Node.js CLI tools crashing inside Docker containers when host-installed node_modules require a newer Node version than the container provides. Use when: (1) "SyntaxError: Invalid regular expression flags" with /v flag in string-width or similar packages, (2) node_modules installed on host with Node 20+ but container has Node 18, (3) `npm install` with file: protocol creates symlinks that break inside Docker, (4) pnpm workspace packages become broken symlinks in containers. Covers version detection, Node binary mounting, and npm install strategies for cross-version compatibility.Key capabilities
- →Detect Node.js version mismatches between host and Docker containers.
- →Diagnose 'SyntaxError: Invalid regular expression flags' errors.
- →Identify issues with host-installed node_modules requiring newer Node versions.
- →Resolve broken symlinks created by 'npm install file:' protocol.
- →Address pnpm workspace package symlink issues in containers.
- →Mount a newer Node.js binary into the container for compatibility.
How it works
The skill diagnoses Node.js version compatibility and symlink issues in Docker containers with host-mounted node_modules, then provides solutions like mounting a compatible Node.js binary or using specific npm/pnpm installation strategies.
Inputs & outputs
When to use docker-node-version-compat-modules
- →Fix Invalid regular expression flag error
- →Resolve node_modules symlink issues in Docker
- →Fix pnpm workspace container crashes
About this skill
Docker Node Version Compatibility for Mounted node_modules
Problem
When mounting host-installed node_modules into a Docker container, packages may require
a newer Node.js version than what's available in the container. This causes cryptic runtime
errors (not install-time errors) because npm doesn't enforce engines constraints by default.
Context / Trigger Conditions
- Primary symptom:
SyntaxError: Invalid regular expression flagson the/vflag (Unicode Sets, requires Node 20+) - Affected packages:
[email protected],[email protected], and their dependents - Scenario: Host has Node 20+, Docker container has Node 18 (common in SWE-bench images)
- Also triggers when:
npm installwithfile:protocol creates symlinks to host paths that don't exist inside the container - Also triggers when: pnpm workspace
@scope/pkgentries are symlinks to../../../../workspace/packages/pkg— broken inside Docker
Root Cause
-
npm doesn't enforce
enginesby default: Even with--engine-strict, it only checks direct dependencies, not transitive ones. Packages like[email protected]declare"engines": {"node": ">=20"}but npm happily installs them on any Node version. -
file:protocol creates symlinks:npm install file:../pathcreates a symlink innode_modules/pointing to the host path. Inside Docker, that host path doesn't exist. -
pnpm workspace symlinks: In pnpm monorepos,
node_modules/@scope/pkgis a symlink to../../packages/pkg. These are relative to the workspace root, not the mount point.
Diagnostic Steps
CRITICAL: Before attempting any fix, verify these first:
-
Check Node version in the target container:
docker run --rm <image> node --version -
Check if the tool actually worked before (don't assume — read the trajectory/logs):
# Look for actual command outputs, not just references in prompts grep '"returncode": 0' trajectory.json | grep grafema -
Check for symlinks in mounted node_modules:
docker exec <container> bash -c "ls -la /opt/node_modules/@scope/"
Solutions
Solution A: Mount Node 20+ Binary (Recommended)
Download a Node.js binary for Linux and mount it alongside node_modules:
# Download once
curl -sL https://nodejs.org/dist/v20.18.0/node-v20.18.0-linux-x64.tar.xz | \
tar -xJ -C /path/to/node20 --strip-components=1
# Mount and use in container
docker run -v /path/to/node20:/opt/node20:ro \
-v /path/to/node_modules:/opt/modules:ro \
<image> bash -c "
export PATH=/opt/node20/bin:\$PATH
# Create wrapper script for the CLI tool
echo '#!/bin/bash' > /usr/local/bin/mytool
echo 'exec /opt/node20/bin/node /opt/modules/.bin/mytool \"\$@\"' >> /usr/local/bin/mytool
chmod +x /usr/local/bin/mytool
"
Solution B: Install with Version Constraints
Install inside a container matching the target Node version with overrides:
docker run --rm -v /path/to/install:/install node:18 bash -c '
cd /install
npm install --engine-strict # Will fail if deps need Node 20+
'
If this fails (because core deps like ink require Node 20+), Solution A is the only option.
Solution C: pnpm pack + npm install (Flat Layout)
For pnpm monorepos, create tarballs first to eliminate workspace symlinks:
# On host (resolves workspace:* protocol)
pnpm -C packages/cli pack --pack-destination /tmp/packs
# Install from tarballs (creates real directories, not symlinks)
# Do this inside a Docker container matching target Node version
docker run --rm -v /tmp/packs:/packs:ro -v /path/to/install:/install node:20 bash -c '
cd /install
cat > package.json << EOF
{"dependencies": {"@scope/cli": "file:/packs/cli-1.0.0.tgz"}}
EOF
npm install
'
Important: Use pnpm pack (not npm pack) to resolve workspace:* protocol.
Anti-Patterns
-
Don't dereference symlinks with
cp -RL: This copies files but npm still resolves the latest dependency versions, which may require newer Node. -
Don't use
pnpm deployfor Docker mounts: It creates.pnpm/layout with internal symlinks that cause ESM resolution errors in some Node versions. -
Don't debug Docker setup without checking if it ever worked: Verify in actual trajectory outputs, not by counting keyword references in prompts/logs.
-
Don't try multiple fixes in sequence without diagnosing: Check Node version compatibility FIRST before attempting any fix.
Verification
# Test the full command, not just the binary path
docker exec <container> bash -c "export PATH=/opt/node20/bin:\$PATH; mytool --version"
# Test a command that exercises dependency loading (not just the entry point)
docker exec <container> bash -c "export PATH=/opt/node20/bin:\$PATH; mytool impact 'someFunction'"
Notes
- SWE-bench Docker images use different Node versions: axios=Node 20, preact=Node 18
grafema overviewmay work whilegrafema impactfails because they load different modules- The
/vregex flag (Unicode Sets) is the most common Node 20 breakage point ink(terminal UI framework) switched to Node 20+ requirement starting from v6.0.0
When not to use it
- →When the problem is not related to Node.js version compatibility in Docker.
- →When node_modules are not mounted from the host into the container.
- →When the error is not 'SyntaxError: Invalid regular expression flags' or symlink related.
Limitations
- →npm does not enforce 'engines' constraints by default for transitive dependencies.
- →'npm install file:' protocol creates symlinks that may break in Docker.
- →pnpm workspace symlinks can be broken inside Docker containers.
How it compares
This skill offers targeted solutions for specific Node.js compatibility and symlink problems within Docker, including binary mounting and package management strategies, which differs from general Docker or Node.js troubleshooting.
Compared to similar skills
docker-node-version-compat-modules side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| docker-node-version-compat-modules (this skill) | 0 | 6mo | Review | Intermediate |
| agent-sandbox | 1 | 6mo | No flags | Intermediate |
| openevidence-deploy-integration | 1 | 27d | Caution | Intermediate |
| DevOps Engineer Skills | 0 | 3mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by Disentinel
View all by Disentinel →You might also like
agent-sandbox
ruvnet
Agent skill for sandbox - invoke with $agent-sandbox
openevidence-deploy-integration
jeremylongshore
Deploy OpenEvidence integrations to healthcare production environments. Use when deploying to production, setting up staging environments, or configuring cloud deployments for clinical AI applications. Trigger with phrases like "deploy openevidence", "openevidence staging", "openevidence production deploy", "release openevidence".
DevOps Engineer Skills
lanmata
Consolidated skill set for the DevOps Engineer agent — Maven build, Docker, GitHub Actions, CI/CD orchestration, and release management
groq-deploy-integration
jeremylongshore
Deploy Groq integrations to Vercel, Fly.io, and Cloud Run platforms. Use when deploying Groq-powered applications to production, configuring platform-specific secrets, or setting up deployment pipelines. Trigger with phrases like "deploy groq", "groq Vercel", "groq production deploy", "groq Cloud Run", "groq Fly.io".
makefile-dev-workflow
raphaelmansuy
Unified development workflow for EdgeQuake using Makefile commands. Use when starting services, running tests, or managing the full development stack (database, backend, frontend). Provides simplified alternatives to raw cargo/npm commands.
e2e-test-service-management
raphaelmansuy
Service management for E2E testing in EdgeQuake. Start, stop, and monitor PostgreSQL, backend API, and frontend services. Includes health checks and logging utilities for interactive testing workflows.