First, use this command to create a package. Then create a package version.
If you don’t have a namespace defined in your sfdx-project.json file, use –no-namespace.
Your –name value must be unique within your namespace.
Run ‘sf package list to list all packages in the Dev Hub org.
Aliases for package create
force:package:create
Flags
Flag Name (Long)
Flag Name (Short)
Description
‑‑api‑version
N/A
Type: Value
Override the api version used for api requests made by this command
‑‑description
‑d
Type: Value
Description of the package.
‑‑error‑notification‑username
‑o
Type: Value
Active Dev Hub user designated to receive email notifications for package errors.
Email notifications include information about unhandled Apex exceptions, and install, upgrade, or uninstall failures associated with your package.
‑‑flags‑dir
N/A
Type: Value
Import flag values from a directory.
‑‑json
N/A
Type: Boolean
Format output as json.
‑‑name
‑n
Type: Value Required
Name of the package to create.
‑‑no‑namespace
‑e
Type: Boolean
Create the package with no namespace; available only for unlocked packages.
This flag is useful when you’re migrating an existing org to packages. But use a namespaced package for new metadata.
‑‑org‑dependent
N/A
Type: Boolean
Depends on unpackaged metadata in the installation org; applies to unlocked packages only.
Use Source Tracking in Sandboxes to develop your org-dependent unlocked package. For more information, see “Create Org-Dependent Unlocked Packages” in the Salesforce DX Developer Guide.
‑‑package‑type
‑t
Type: Value Required Valid Values:Managed, Unlocked
Type of package.
The options for package type are Managed and Unlocked (Managed=DeveloperManagedSubscriberManaged, Unlocked=DeveloperControlledSubscriberEditable). These options determine upgrade and editability rules.
‑‑path
‑r
Type: Value Required
Path to directory that contains the contents of the package.
‑‑target‑dev‑hub
‑v
Type: Value Required
Username or alias of the Dev Hub org. Not required if the target-dev-hub configuration variable is already set.
Examples for package create
Create an unlocked package from the files in the “force-app” directory; uses your default Dev Hub org: