Before getting started, you will need to install Node.js >= version 16, it is recommended to use the Node.js LTS version.
Check the current Node.js version with the following command:
If you do not have Node.js installed in current environment, or the installed version is too low, you can use nvm or fnm to install.
Here is an example of how to install via nvm:
You can use the create-rslib
to create a new Rslib project. Run the following command:
Then follow the prompts to complete the operation.
create-rslib
is a tool for quickly creating Rslib projects. When creating a project, you can choose from the following templates:
Template | Description |
---|---|
Node.js dual ESM/CJS package | Node.js dual ESM/CJS package |
Node.js pure ESM package | Node.js pure ESM package |
React | React component library |
Each template supports both JavaScript and TypeScript, along with optional development tools, formatters, and linters.
We're working to provide templates for more frameworks (such as Vue).
create-rslib
can help you set up some commonly used development linter tools, including Vitest, Storybook. You can use the arrow keys and the space bar to make your selections. If you don't need these tools, you can simply press Enter to skip.
create-rslib
can help you set up some commonly used formatter and linter tools, including Biome, ESLint, and prettier. You can use the arrow keys and the space bar to make your selections. If you don't need these tools, you can simply press Enter to skip.
Biome provides similar linting and formatting features to ESLint and Prettier. If you select Biome, you typically won't need to choose ESLint or Prettier as well.
If you need to create a project in the current directory, you can set the target folder to .
:
create-rslib provides some CLI flags. By setting these CLI flags, you can skip the interactive selection steps and create the project with one command.
For example, to create an example project in the my-project
directory with one command:
All the CLI flags of create-rslib
:
If you need to migrate from an existing project to Rslib, you can refer to the following guides: