Skip to content

Latest commit

 

History

History
101 lines (61 loc) · 4.89 KB

README.md

File metadata and controls

101 lines (61 loc) · 4.89 KB

Node.js Starter

A minimalistic template for starting a new Node.js project.

This template provides a basic Node.js project containing a sample library written in TypeScript, with support for formatting, linting, testing, and continuous integration.

Key Features

Usage

This guide explains how to use this template to start a new Node.js project, from creation to release.

Create a New Project

Follow this link to create a new project based on this template. For more information about creating a repository from a template on GitHub, refer to this documentation.

Alternatively, you can also clone this repository locally to begin using this template.

Choose a License

By default, this template is unlicensed. Before modifying this template, it is recommended to replace the LICENSE file with the license that will be used by the new project. For more information about licensing a repository, refer to this documentation.

Alternatively, you can remove the LICENSE file or leave it as is to keep the new project unlicensed.

Update Project Information

To replace the sample information in this template with your new project information, complete the following steps:

  • Replace the content of this README.md file with a description of the new project. For more information on adding READMEs to a project, refer to this documentation.
  • Update project information in the package.json file. For more details on the package.json schema, refer to this documentation.

Set Up Tools

It is recommended to use nvm to manage the Node.js version in the project. By default, this template uses the Node.js version specified in the .nvmrc file. Use the following command to install and use the correct Node.js version with nvm:

nvm install

This template uses Yarn with Plug'n'Play support as the package manager. If Yarn is not yet enabled, run the following command:

corepack enable yarn

Then, install the project dependencies with:

yarn install

For more information on Yarn, such as adding dependencies or running tools, refer to this documentation.

Developing the Library

This template provides two components: the library itself (src/index.ts) and an executable entry point (src/bin.ts). Write code according to your project requirements. If you're new to TypeScript, refer to this documentation for guidance.

If your project doesn’t need an executable, you can remove src/bin.ts and the bin entry from the package.json file.

Once the code is written, format it with:

yarn format

Then, check linting with:

yarn lint

To ensure the source code compiles correctly, use:

yarn build

Testing the Library

Test files in this template are named *.test.ts and typically correspond to the source files being tested. This template uses Jest as the testing framework. For more information on testing with Jest, refer to this documentation.

After creating your test files, run tests with:

yarn test

Release the Library

When the project is complete, package the library by running:

yarn pack

This will create a package.tgz file, which can be included in the release. Ensure the project is at the correct version and has been pushed to the upstream repository. For more information on releasing a project, refer to this documentation.