Overview
Devark automatically detects your package manager and uses it to install dependencies. It supports:- npm - Node Package Manager (default)
- pnpm - Fast, disk-efficient package manager
- yarn - Fast, reliable, and secure dependency management
- bun - All-in-one JavaScript runtime and toolkit
You never need to manually specify your package manager. Devark figures it out automatically by checking for lock files or environment variables.
Auto-Detection Logic
Devark uses a two-phase detection strategy:1. Lock File Detection
Devark first checks for lock files in your project directory:src/utils/packageManager.js
- Check for
pnpm-lock.yaml→ returnpnpm - Check for
yarn.lock→ returnyarn - Check for
package-lock.json→ returnnpm - Check for
bun.lockorbun.lockb→ returnbun - If none found → return
null
Why this order matters
Why this order matters
The order prioritizes specificity:
- pnpm and yarn have unique lock files
- npm is checked before bun as it’s more common
- bun can coexist with other lock files, so it’s checked last
2. Command Detection (Fallback)
If no lock file is found, Devark checks thenpm_config_user_agent environment variable:
src/utils/packageManager.js
The
npm_config_user_agent variable is automatically set by package managers when running scripts. For example:yarn/1.22.19 npm/? node/v18.0.0pnpm/8.6.0 npm/? node/v18.0.0
Detection in Action
When you install a module, you’ll see detection messages:Lock File Behavior
Each package manager creates specific lock files:- npm
- pnpm
- yarn
- bun
- Running
npm install - Installing packages with
npm install <package>
- Locks exact versions of all dependencies
- Ensures reproducible installs
- Speeds up subsequent installs
Installation Commands
Devark uses the appropriate command for each package manager:src/utils/packageManager.js
Command Comparison
| Action | npm | yarn | pnpm | bun |
|---|---|---|---|---|
| Install deps | npm install | yarn | pnpm install | bun install |
| Add package | npm install pkg | yarn add pkg | pnpm add pkg | bun add pkg |
| Add dev dep | npm install -D pkg | yarn add -D pkg | pnpm add -D pkg | bun add -d pkg |
| Remove package | npm uninstall pkg | yarn remove pkg | pnpm remove pkg | bun remove pkg |
| Run script | npm run dev | yarn dev | pnpm dev | bun dev |
Manual Override
If detection fails, Devark provides fallback instructions:- npm
- pnpm
- yarn
- bun
Best Practices for Teams
Document Your Choice
Add to your README:Do not use npm or yarn.This prevents team members from accidentally using the wrong package manager.
README.md
Commit Lock Files
Always commit your lock file:
.gitignore
CI/CD Consistency
Use the same package manager in CI:
.github/workflows/ci.yml
Choosing a Package Manager
- npm
- pnpm
- yarn
- bun
Best for:
- Beginners
- Maximum compatibility
- Projects with strict auditing needs
- Built into Node.js
- Largest ecosystem
- Well-documented
- Automatic security audits
- Slower than alternatives
- Uses more disk space
- No native workspace support (until v7)
Speed Comparison
Based on typical project installs:These are approximate values for a medium-sized Express project. Your mileage may vary.
Troubleshooting
Wrong package manager detected
Wrong package manager detected
This happens when you have multiple lock files:Then reinstall with your preferred manager.
'Could not detect package manager' error
'Could not detect package manager' error
If Devark can’t detect your package manager:
-
Initialize your project first:
-
Or create a lock file manually:
-
Then run Devark again:
Dependencies installed with wrong package manager
Dependencies installed with wrong package manager
If someone on your team used the wrong package manager:
Lock file conflicts in Git
Lock file conflicts in Git
When merging branches with lock file conflicts:
Source Code Reference
Devark’s package manager detection is implemented in:src/utils/packageManager.js:7-21-detectPackageManager()functionsrc/utils/packageManager.js:79-86-detectByCommand()fallbacksrc/utils/packageManager.js:24-43-installDependencies()with command mappingsrc/utils/packageManager.js:58-76-installDepsWithChoice()for runtime/dev deps
Advanced: Workspaces
If you’re using monorepos, each package manager has workspace support:- npm workspaces
- pnpm workspaces
- yarn workspaces
package.json
Devark works seamlessly with workspaces. It will detect the package manager and install dependencies in the correct workspace package.

