Warning
Onyx is still in its early development stage and not a production-ready type of software. It might behave in some unexpected ways.
Onyx is a Node.js package manager built with Go (yes, ironically) and the Cobra CLI framework. It allows you to manage your Node.js dependencies without relying on traditional package managers like npm, yarn or even pnpm. The tool provides features for installing, removing, and running scripts from package.json, with additional support for handling devDependencies.
- Install a Single Package: Install individual Node.js packages directly from the npm registry.
- Install All Dependencies: Install all dependencies listed in
package.json. - Install as DevDependencies: Install a package as a devDependency using a flag.
- Remove a Package: Remove a package from
node_modulesandpackage.json. - Run Custom Scripts: Run custom npm scripts defined in the
scriptssection ofpackage.json. - Install Global Packages: Install packages globally with permissions management.
- Graceful Error Handling: Handles missing or incomplete package metadata gracefully and skips problematic packages.
- Custom Lockfile: After a package installation Onyx has a special
.onyxlock.yamlfile in order to track dependency tree in project directory.
-
Clone the repository:
git clone https://github.com/alperencantez/onyx.git
-
Change to the project directory:
cd onyx -
Build the CLI tool:
go build -o . -
Move the binary to your
$PATHfor global usage:sudo mv onyx /usr/local/bin/
Onyx is distributed via npm.
You can run
npm i @cantez/onyx -gNote
Due to a third-party dependency it can only be obtained through npm. Do not attempt to get it with a yarn add.
Now you can use onyx from any directory!
To install a package:
onyx get next 14.1.3To install a package as a devDependency:
onyx get lodash --devIf you already have a package.json file, you can install all dependencies listed:
onyx depsThis command installs all dependencies and devDependencies listed in the package.json file.
To remove a package from node_modules and package.json:
onyx remove lodashThis will delete the lodash package from your node_modules and remove its entry from the package.json file.
You can run custom scripts defined in the scripts section of your package.json:
onyx r buildThis will execute the build script defined in your package.json.
To install a package globally:
sudo onyx get lodash -gThis command installs lodash globally in your system.
The tool provides graceful error handling for cases such as:
- Missing
package.json. - Missing
node_modules. - Packages with incomplete metadata in the npm registry.
- Invalid or malformed versions (e.g.,
^and~symbols).
In cases where a package cannot be installed due to missing metadata or other issues, warnings will be logged, but the process will continue for other packages:
Warning: 'dist' field is missing for package 'gsap'. Skipping installation.-
Clone the repository:
git clone https://github.com/alperencantez/onyx.git
-
Make your changes.
-
Run the project locally:
go run main.go
If you’d like to contribute, please fork the repository and use a feature branch. Pull requests are welcome!
-
Fork the repo and create your branch:
git checkout -b feature/my-feature
-
Make changes and commit them:
git commit -m "Add new feature" -
Push to the branch:
git push origin feature/my-feature
-
Create a PR.
This project is licensed under the MIT License. See the LICENSE file for details.