Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Dependency @types/html2canvas must be explicitly allowed using the "allowedNonPeerDependencies" option

I have installed the html2canvas in my angular library project and, when I compile in production mode (running the ng build --prod command), I'm receiving the following error:

ERROR: Dependency @types/html2canvas must be explicitly allowed using the "allowedNonPeerDependencies" option.

How can I solve it?

like image 588
Ricardo Rocha Avatar asked Dec 09 '22 23:12

Ricardo Rocha


1 Answers

You can add the library to your peerDependencies in package.json. I strongly recommend using the peerDependencies strategy since exposes explicitly to others that your library depended on other libraries:

{
    ...
    "scripts": {...},
    "peerDependencies": {
        ...
        "@types/html2canvas": "0.0.36",
        ...
    },
}

Or you can use the option on your ng-package.json:

{
    ...
    "lib": {
        "entryFile": "src/public-api.ts"
    },
    "allowedNonPeerDependencies": [
        "@type/html2canvas"
    ]
    ...
}
like image 113
Ricardo Rocha Avatar answered Jan 04 '23 23:01

Ricardo Rocha