[SalesForce] Unlocked Package Dependency Missing Organization Feature Knowledge

Error when creating new version of unlocked package.

An error occurred while trying to install a package dependency,ID 04XXX: Missing Organization Feature: Knowledge

sfdx-project-json

        "path": "force-app",
        "default": true,
        "package": "memberone",
        "versionName": "July 22 2019",
        "versionNumber": "0.2.11.NEXT",
        "definitionFile": "config/project-scratch-def.json",
        "dependencies": [...

config/project-scratch-def.json

    {
"orgName": "MemberOne",
"edition": "Enterprise",
"features": ["Communities", "Sites", "Knowledge"],
"settings" : {
    "orgPreferenceSettings": {
        "chatterEnabled": true,
        "s1DesktopEnabled": true,
        "networksEnabled": true,
        "knowledgeEnabled": true
},
    "knowledgeSettings":{
        "enableKnowledge": true,
        "enableLightningKnowledge": true,
        "
    }
}

}

When I use the scratch-def to create scratch org directly it seems to work fine and dependent package 04XX installs.

Best Answer

The force:package:version:create command takes a definition file as an optional argument, where you can specify the required dependencies:

-f | --definitionfile DEFINITIONFILE
Optional
The path to a definition file similar to scratch org definition file that
contains the list of features and org preferences that the metadata of the
package version depends on.

Despite the phrasing "similar to", as far as I know it's exactly the same as your project's standard scratch org configuration file, as illustrated in Generate a Package Version.

That sets the shape of the under-the-hood scratch org used to build the package version.