Use nvm to use the appropriate Node.js version from .nvmrc:
nvm iInstall the dependencies using npm:
npm iRun the build script:
npm buildThe package is bundled using pkgroll (Rollup). It infers the entry-points from package.json so there are no build configurations.
During development, you can use the watch flag (--watch, -w) to automatically rebuild the package on file changes:
npm build -wSince pkgroll knows the entry-point is a binary (being in package.json#bin), it automatically adds the Node.js hashbang to the top of the file, and chmods it so it's executable.
You can run the distribution file in any directory:
./dist/cli.mjsOr in non-UNIX environments, you can use Node.js to run the file:
node ./dist/cli.mjsFirst, install prettier.
npm install -g prettierOnce Prettier is installed, you can run it on a single file or multiple files using the following commands:
- For a single file:
prettier --write path/to/your/file.js- For a multiple file:
prettier --write "src/**/*.js"If you use Vscode, It is recommended to use prettier-vscode