Skip to content

配置项

项目描述

字段含义
name包名,必须小写,中间用 -,不能有空格
version版本号,遵循 semver 规范(主版本.次版本.修订号
description项目描述
author作者信息
license开源许可证,如 MIT、ISC、Apache-2.0 等
json
{
  "name": "demo",
  "version": "1.0.0",
  "description": "一个示例项目",
  "author": "赖",
  "license": "MIT"
}

模块类型

json
{
  "type": "module"
}
配置作用
type: "module".js 文件按 ESM 解析,可以使用 import/export
type: "commonjs"(默认).js 文件按 CommonJS 解析,使用 require/module.exports

脚本

json
{
  "scripts": {
    "dev": "node index.js",
    "start": "node index.js",
    "build": "tsc",
    "test": "echo \"No tests\" && exit 0"
  }
}

依赖管理

json
{
  "dependencies": {
    "vue": "^3.3.4"
  },
  "devDependencies": {
    "typescript": "^5.2.2",
    "vite": "^5.2.0"
  }
}