目录

ohpm init

Creates an oh-package.json5 file.

Command Format

ohpm init [options]

Description

This command is used to create an oh-package.json5 file and initialize a package in the working directory.

During the command execution, an interaction interface is displayed for you to input basic information about the third-party library, such as the library name and version. ohpm creates an oh-package.json5 file in the working directory based on existing fields, dependencies, and selected options. The set fields and values will all be retained.

Options

[h2]yes

Besides creating the default oh-package.json5 file, you can append the -y or --yes parameter to the ohpm init command to skip the interaction interface.

The default content is as follows:

{
    "name": "work_dir",
    "version": "1.0.0",
    "description": "",
    "main": "Index.ets",
    "author": "",
    "license": "ISC",
    "dependencies": {}
  }

If there is no existing oh-package.json5 file in the current working directory, the name field in the new file is the name of the current working directory by default. If there is already an oh-package.json5 file, the new file overwrites the existing one, with the name field set to the same value as that in the existing file.

[h2]group

You can append the -g <group_name> or --group <group_name> parameter to the ohpm init command to create an oh-package.json5 file. The namespace of the name field is @group_name.

[h2]log_level

In ohpm 6.0.2.636 and later versions, you can append the --log_level <string> parameter to the ohpm init command to specify the log level (info, debug, warn, or error) for execution of the current command. If this parameter is not set, the log_level setting in the .ohpmrc file is applied.

[h2]debug

In ohpm 6.0.2.636 and later versions, you can append the --debug parameter to the command to set the log level to debug for execution of the current command. This configuration takes effect only on the current command line and does not alter the log level configured in the .ohpmrc file. If this parameter is not set, the log_level setting in the .ohpmrc file is applied.

Example