npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ly-node-api-cli

v1.0.14

Published

快速搭建一个node+express+ts的接口项目的脚手架

Downloads

203

Readme

ly-node-api-cli

本脚手架用于快速创建一个 Express + TypeScript 的后端项目框架。
该工具基于 Commander、Inquirer、fs-extra、chalk 等库实现交互式命令行项目创建。


功能特点

  • 快速创建 Node + Express + TypeScript 项目。
  • 自动生成基础配置文件,如 tsconfig.jsonesbuild.js.env 等。
  • 提供预设的路由和中间件,帮助快速实现常见功能。
  • 支持选择是否安装依赖。
  • 提供了开发、打包、生产环境等常用命令提示。

安装

在使用 ly-node-api-cli 前,您需要先将其安装为全局命令工具:

npm install -g ly-node-api-cli

使用

初始化一个新项目

创建新项目的命令如下:

create-express

命令行操作流程

  1. 创建项目目录 系统会自动根据您提供的项目名称创建相应的项目目录,并在其中生成所有基础文件。

  2. 是否安装依赖 在项目初始化过程中,系统会询问您是否安装依赖。如果选择安装,系统将自动运行 npm install

  3. 进入项目目录 项目创建完成后,您可以进入项目目录:

    cd 项目名称
    
  4. 安装项目依赖 如果您在创建项目时没有选择自动安装依赖,您可以手动运行以下命令:

    npm install
    
  5. 启动开发环境 安装完依赖后,您可以启动开发环境:

    npm run dev
    
  6. 打包项目 如果您需要将项目打包,可以运行以下命令:

    npm run build
    
  7. 启动生产环境 完成打包后,您可以启动生产环境:

    npm start
    

可选步骤

  • 如果您希望跳过某些步骤,例如不安装依赖,系统会提供相应的提示,您可以按需执行。

常见问题解答 (FAQ)

  1. 如何修改项目配置? 您可以根据需要修改生成的 tsconfig.jsonesbuild.jspackage.json 等配置文件。项目已根据最佳实践配置,您可以根据项目需求调整。

  2. 如何扩展功能? ly-node-api-cli 创建的项目结构是模块化的,您可以在 src/middlewares/ 中添加新的中间件,在 src/routes/ 中添加新的路由,在 src/utils/ 中添加工具函数等。

  3. 如何运行测试? 项目模板默认不包含测试配置,您可以根据需求添加测试框架(如 Jest、Mocha 等)来编写测试。

  4. 如何打包项目? 在项目根目录运行 npm run build,该命令会使用 esbuild 将 TypeScript 项目打包为 JavaScript 文件。

  5. 如何处理环境变量? 项目模板包含 .env.development.env.production 文件。您可以在这些文件中添加需要的环境变量,dotenv 会自动加载这些配置。