Stop memorizing commands. Start building.
np is a blazingly fast, intelligent package manager proxy that automatically detects and forwards commands to the right package manager (npm, yarn, or pnpm) in your project. Write once, run anywhere.
Ever switched between projects and typed the wrong command?
# In a pnpm project
$ npm install axios
# ❌ Wrong package manager!
# In a yarn project
$ pnpm add lodash
# ❌ Wrong again!Managing multiple projects with different package managers is painful. You need to:
- ✋ Remember which package manager each project uses
- ✋ Check for lock files before running commands
- ✋ Context-switch between npm, yarn, and pnpm commands
np does the thinking for you.
# Works everywhere, automatically
$ np install axios
$ np add lodash
$ np run dev
$ np --versionOne command to rule them all. np automatically:
- 🔍 Detects the package manager from
package.jsonor lock files - ⚡ Forwards all commands and arguments seamlessly
- 💾 Optionally saves your choice for future runs
- 🚀 Runs with near-zero overhead (written in Rust)
- 🧠 Smart Detection: Reads
packageManagerfield inpackage.jsonor scans lock files - ⚡ Zero Config: Works out of the box, no setup required
- 🔄 Full Compatibility: All npm/yarn/pnpm commands work exactly as expected
- 💪 Blazingly Fast: Built with Rust for maximum performance
- 🎨 Interactive Mode: Prompts you when multiple package managers are detected
- 💾 Persistent Choices: Save your selection to
package.jsonautomatically - 🔧 Battle-Tested: Comprehensive test suite with 34+ tests
cargo install npgit clone https://github.com/jordyfontoura/np.git
cd np
cargo build --release
sudo mv target/release/np /usr/local/bin/Download the latest binary from Releases
Once installed, just replace your package manager command with np:
# Instead of:
npm install
yarn install
pnpm install
# Just use:
np installThat's it! np will figure out the rest.
All your favorite commands work exactly the same:
# Installing dependencies
np install
np add axios
np add -D typescript
# Running scripts
np run dev
np run build
np test
# Getting info
np --version
np listWhen np can't determine the package manager, it will ask you:
$ np install
🤔 Could not determine the package manager.
? Which package manager would you like to use?
> npm
yarn
pnpm
? Would you like to save this choice in the 'packageManager' field in package.json? (Y/n)Select your preferred package manager, and optionally save it to avoid future prompts.
np follows this detection order:
-
packageManagerfield inpackage.json(highest priority){ "packageManager": "[email protected]" } -
Lock files in the project directory:
package-lock.json→ npmyarn.lock→ yarnpnpm-lock.yaml→ pnpm
-
Interactive prompt (when multiple or none are detected)
cd frontend/ # Uses yarn
np install # ✅ Runs: yarn install
cd ../backend/ # Uses pnpm
np install # ✅ Runs: pnpm install
cd ../legacy/ # Uses npm
np install # ✅ Runs: npm install# Clone any project
git clone https://github.com/some/project.git
cd project
# Just use np - it adapts automatically
np install
np run test
np run build# .github/workflows/ci.yml
- name: Install dependencies
run: np install
- name: Run tests
run: np test
- name: Build
run: np run build-
Detection Phase:
- Scans
package.jsonforpackageManagerfield - Falls back to detecting lock files (
package-lock.json,yarn.lock,pnpm-lock.yaml) - Prompts user if detection is ambiguous
- Scans
-
Execution Phase:
- Spawns the detected package manager with all original arguments
- Inherits stdin/stdout/stderr for seamless integration
- Preserves exit codes and signals
-
Persistence (Optional):
- Saves user choice to
package.json→packageManagerfield - Ensures consistent behavior across team members
- Saves user choice to
np comes with a comprehensive test suite:
# Run all tests
cargo test
# Run specific test suites
cargo test --test package_detector_tests
cargo test --test script_handler_tests
cargo test --test command_executor_testsTest Coverage:
- ✅ 10 package detection tests
- ✅ 15 package.json read/write tests
- ✅ 9 command execution tests
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run the test suite:
cargo test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with the amazing Rust ecosystem
- Thanks to all contributors and users!
If np saves you time and mental overhead, please consider:
- ⭐ Starring the repository
- 🐛 Reporting bugs and suggesting features
- 📢 Sharing with your team and friends