Adding packages for custom plugins

Hello!

Recently, I was trying to make my own plugin for exporting data to pdf. I wanted to use package “pdf-lib”, however I have a small problem: I don’t now how to install packages (yarn add or npm install). I tried installing packages globally, but when I build plugin, I get an error “Error: Cannot find module”. I also tried building built-in “plugin-action-export” and got the same error for package “xlsx”, even though it is installed.

Can you help me? Thanks in advance!

There are two methods you can try:

  1. Add the dependencies to the devDependencies part of the package.json of your own plugin.
{
  "devDependencies": {
    "pdf-lib": "xxx"
  }
}

Then run yarn install under the root directory.

  1. Run npx lerna add pdf-lib --scope={plugin-package-name} --dev under the root directory.
1 Like

Thanks! That worked, but I now have this error when I am trying to build xlsx export plugin(built-in):

Do you know how to fix that?

Build the core packages by running yarn build packages/core under the root directory before building your own plugin for the first time.