Usage

Modern.js provides @modern-js/create tool for creating project templates provided by Modern.js, including Web App, Npm Module.

The following will introduce how to use @modern-js/create.

Environment Preparation

Node.js

Before getting started, you will need to install Node.js, and ensure that your Node.js version is higher than 16.2.0. We recommend using the LTS version of Node.js 18.

You can check the currently used Node.js version with the following command:

node -v

If you do not have Node.js installed in your current environment, or the installed version is lower than 16.2.0, you can use nvm or fnm to install the required version.

Here is an example of how to install the Node.js 18 LTS version via nvm:

# Install the long-term support version of Node.js 18
nvm install 18 --lts

# Make the newly installed Node.js 18 as the default version
nvm alias default 18

# Switch to the newly installed Node.js 18
nvm use 18
nvm and fnm

Both nvm and fnm are Node.js version management tools. Relatively speaking, nvm is more mature and stable, while fnm is implemented using Rust, which provides better performance than nvm.

pnpm

It is recommended to use pnpm to manage dependencies:

npm install -g pnpm@8
NOTE

Modern.js also supports dependency management with yarn and npm.

Create a Project with @modern-js/create

You do not need to install @modern-js/create globally, just use npx to run it:

npx @modern-js/create@latest [projectDir]
INFO

[projectDir] is the project directory name. If it is not filled in, the project will be created in the current directory.

During the execution, complete the interaction according to the prompt to create a project that meets your requirements.

Create an Web APP Project

npx @modern-js/create@latest web-app
? Please select the type of project you want to create: Web App
? Please select the programming language: TS
? Please select the package manager: pnpm

Create an Npm Module Project

npx @modern-js/create@latest npm-module
? Please select the type of project you want to create: Npm Module
? Please fill in the project name: npm-module
? Please select the programming language: TS
? Please select the package manager: pnpm