xiaohongshu
xiaohongshu
elastic-beanstalk-deployment
Use when deploying Node.js applications to AWS Elastic Beanstalk or troubleshooting deployment issues - provides dependency installation strategies, monorepo handling, and deployment best practices
Full skill instructions
AWS Elastic Beanstalk automates Node.js application deployment but has specific behaviors around dependency installation that can cause issues, especially with monorepos. Understanding when EB installs dependencies vs when it skips installation is critical for successful deployments.
Core principle: Choose between letting EB install dependencies (smaller packages, slower) or bundling node_modules (larger packages, more reliable).
Use when:
Don't use for:
Reference: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-dependencies.html
| Condition | EB Action | npm Command |
|---|---|---|
package.json exists, NO node_modules/ | Installs dependencies | npm install --omit=dev (npm 7+) |
node_modules/ directory present | Skips installation | None - uses bundled modules |
Best for: Simple apps, all packages in npm registry, no monorepo
# GitHub Actions workflow
- name: Build application
run: npm run build
- name: Create deployment package
run: |
zip -r app.zip \
dist/ \
package.json \
package-lock.json \
.ebextensions/
Pros:
Cons:
Best for: Monorepos, private packages, reliability requirements
AWS official quote: "Bundle node_modules to bypass potential npm registry installation issues."
# GitHub Actions workflow
- name: Install production dependencies
run: npm install --omit=dev
- name: Create deployment package
run: |
zip -r app.zip \
dist/ \
package.json \
node_modules/ \
.ebextensions/
Pros:
Cons:
Running npm ci --production inside a monorepo workspace:
node_modules (~3MB instead of ~50MB)Example error:
Error: Cannot find module '@prpm/types'
Install dependencies outside the workspace context to get real files instead of symlinks:
- name: Create standalone package.json
run: |
mkdir -p /tmp/clean-install
cd /tmp/clean-install
# Copy package.json and replace workspace refs with file paths
cp $GITHUB_WORKSPACE/packages/app/package.json .
jq --arg workspace "$GITHUB_WORKSPACE" \
'.dependencies["@workspace/pkg"] = "file:\($workspace)/packages/pkg"' \
package.json > package.json.tmp
mv package.json.tmp package.json
- name: Install dependencies (outside workspace)
run: |
cd /tmp/clean-install
npm install --omit=dev --legacy-peer-deps
# Verify critical packages (real directories, not symlinks)
test -d node_modules/pg || exit 1
test -d node_modules/@workspace/pkg/dist || exit 1
- name: Copy to deployment location
run: |
rm -rf packages/app/node_modules
cp -r /tmp/clean-install/node_modules packages/app/
Key steps:
file: referencesnode_modules in deploymentSet in Beanstalk console:
NPM_USE_PRODUCTION=false
In package.json:
{
"engines": {
"node": "20.x"
}
}
Note: Version range feature not available on Amazon Linux 2023
When bundling node_modules, migrations can run immediately:
# .ebextensions/migrations.config
container_commands:
01_run_migrations:
command: npm run migrate
leader_only: true
Why this works with bundled approach:
/var/app/staging/node_modules/ already present (bundled)npm install stepSymptoms:
Error: Cannot find module 'pg'
Error: Cannot find module '@prpm/types'
Cause: Package not installed or symlinked
Solution:
# Verify package exists as real directory
ls -la node_modules/pg
file node_modules/@prpm/types # Should show "directory", not "symbolic link"
# If symlink, use clean context installation (see above)
Symptoms:
npm ERR! Could not resolve dependency: @workspace/package
Cause: Workspace package not in npm registry
Solution: Use bundled node_modules approach with clean context installation
Symptoms:
Error: The module was compiled against a different Node.js version
Cause: Native modules compiled for macOS/Windows, deployed to Linux
Solution:
--platform=linux flag for specific packagesCause: Dev dependencies or unnecessary files included
Solution:
# Use --omit=dev flag
npm install --omit=dev
# Exclude unnecessary files
zip -r app.zip dist/ package.json node_modules/ .ebextensions/ \
-x "*.cache/*" "*.test.js" "*.spec.js"
# Use .ebignore file
echo "*.test.js" >> .ebignore
echo "*.spec.js" >> .ebignore
Before deploying, always verify:
# 1. Check node_modules size (should be 50MB+ for typical apps)
du -sh node_modules
# Expected: 50M-100M (if bundled)
# Red flag: 3M-5M (likely symlinks)
# 2. Verify critical packages exist
ls -la node_modules/pg
ls -la node_modules/fastify
ls -la node_modules/@your-workspace/package
# 3. Check for symlinks (should see real directories)
file node_modules/@your-workspace/package
# Expected: "directory"
# Red flag: "symbolic link to ../../packages/your-package"
# 4. Verify dist directories for workspace packages
test -d node_modules/@your-workspace/package/dist || echo "ERROR: dist missing"
# 5. Test the deployment package locally
unzip -q app.zip -d /tmp/test-deploy
cd /tmp/test-deploy
node dist/index.js # Should start without errors
✅ Do: Include package-lock.json for reproducible builds
zip -r app.zip dist/ package.json package-lock.json node_modules/
❌ Don't: Omit lock file or use only package.json
# Inspect before uploading
unzip -l app.zip | grep node_modules | head -20
# Check size
ls -lh app.zip
# Should be: 50-100MB (bundled) or 5-10MB (unbundled)
# Extract and test the exact deployment package
unzip app.zip -d /tmp/deployment-test
cd /tmp/deployment-test
npm start # Should work without any npm install
When switching from unbundled to bundled (or vice versa):
Save successful deployment packages for rollback:
aws s3 cp app.zip s3://my-bucket/deployments/app-$(date +%Y%m%d-%H%M%S).zip
Does your app use monorepo workspace packages?
├─ Yes → Use bundled node_modules (Strategy 2)
│ └─ Install in clean context (outside workspace)
└─ No → Do you need maximum reliability?
├─ Yes → Use bundled node_modules (Strategy 2)
│ └─ Faster deploys, no registry issues
└─ No → Are all packages in public npm registry?
├─ Yes → Let EB install (Strategy 1)
│ └─ Smaller packages, standard approach
└─ No (private packages) → Use bundled node_modules (Strategy 2)
This project uses bundled node_modules approach because:
@prpm/types is a workspace package (not in npm registry)pg package available immediatelySee .github/workflows/deploy-registry.yml for full implementation.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience