Using NPM
Lifo provides annpm command that works like standard NPM:
/usr/lib/node_modules/ and can be imported in Node.js scripts:
The Lifo Package Manager
Thelifo command manages Lifo-specific packages that provide shell commands:
Installing Lifo Packages
Lifo packages are NPM packages prefixed withlifo-pkg- that provide shell commands:
- The package is downloaded from NPM to
/usr/lib/node_modules/ - Commands defined in the package manifest are registered
- You can use the command immediately
List Installed Packages
Remove Packages
- Unregisters all commands from the package
- Removes the package directory from
/usr/lib/node_modules/
Creating Lifo Packages
Edit the command
Open The command receives two arguments:
commands/my-tool.js and implement your command:ctx- CommandContext with args, env, cwd, vfs, stdout, stderr, signal, stdinlifo- LifoAPI with import(), loadWasm(), resolve(), cdn helpers
Package Manifest
Lifo packages use a speciallifo field in package.json:
lifo.commands object maps command names to JavaScript entry points. You can register multiple commands or aliases.
Dev Linking for Development
During development, uselifo link to test packages without publishing:
- Are registered in
/home/user/.lifo-links.json - Commands are loaded from the source directory
- Changes take effect immediately (no reinstall needed)
- Persist across sessions if persistence is enabled
Unlinking
Advanced: Using the Lifo API
Commands receive alifo object with helper methods:
Import ESM Modules from CDN
Load WebAssembly
Resolve Paths
Complete Example: Image Processor
Here’s a complete example of a lifo package that processes images:Using Packages from TypeScript
You can also register and use packages programmatically:Searching for Packages
lifo-pkg- and displays results:
Environment Variables
NPM_REGISTRY
Change the NPM registry:LIFO_CDN
Change the ESM CDN forlifo.import():
Source Code Reference
Package system implementation:- Command: See Commands: System for
lifoandpkgcommands - Runtime: Exported via
createLifoCommandandreadLifoManifestfrom@lifo-sh/core - Dev links: Exported via
linkPackageandunlinkPackagefrom@lifo-sh/core