Reputation: 16266
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?
Upvotes: 16
Views: 21471
Reputation: 16266
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"
]
...
}
Upvotes: 35