我们强烈建议在你的包目录中包含一个 README.md 文件,因为它有助于开发者在 npm 上找到你的包,并在他们的项目中使用你的代码时获得良好的体验。在大多数情况下,README.md 文件包括有关如何 安装配置使用 你包中的代码的说明;以及用户可能会觉得有用的其他信息。就像在任何 GitHub 仓库中一样,README.md 文件将在包的页面上显示。在 npmjs.com 上,README.md 会通过 GitHub 的 APIGitHub 风格的 Markdown 渲染。

🌐 We highly recommend including a README.md file in your package directory as it helps developers find your package on npm and have a good experience using your code in their projects. In most cases README.md files include directions for installing, configuring, and using the code in your package; as well as any other information a user may find helpful. Just like in any GitHub repository, the README.md file will be rendered on the package's page. On npmjs.com, the README.md is rendered as GitHub Flavored Markdown via GitHub's API.

npm 包 README.md 文件 必须 位于包的根目录下。

🌐 An npm package README.md file must be in the root-level directory of the package.

创建并将 README.md 文件添加到包中

🌐 Creating and adding a README.md file to a package

  1. 在文本编辑器中,在你的包根目录下,创建一个名为 README.md 的文件。
  2. README.md 文件中,添加有关你的包的有用信息。
  3. 保存 README.md 文件。

注意: 文件扩展名 .md 表示这是一个 Markdown 文件。有关 Markdown 的更多信息,请参阅 GitHub 指南 “掌握 Markdown”。

更新现有的软件包 README.md 文件

🌐 Updating an existing package README.md file

README.md 文件只有在你发布新版本的包时才会在包页面上更新。要更新你的 README.md 文件:

🌐 The README.md file will only be updated on the package page when you publish a new version of your package. To update your README.md file:

  1. 在文本编辑器中,更新 README.md 文件的内容。

  2. 保存 README.md 文件。

  3. 在命令行上,在包根目录中,运行以下命令:

    npm version patch
    npm publish