Is there a proper way to install local plugin's dependencies?

I found the issue related to this question.

but I cannot find npm run setup command

My temporary fix is adding postinstall script on package.json.
Is it a proper way to do it?

  "scripts": {
    "postinstall": "npm i --prefix plugins/my-plugin1 && npm i --prefix plugins/my-plugin2"

That command was from the alpha, what version of Strapi are you using currently?

Im currently using 3.1.7 and planning upgrade to 3.2.5

Any update on this issue?

@darron1217 let me poke some of our backend engineers as I believe these should be installed but want to confirm.

@alexandrebodin @Convly @Pierre_Noel

Hi, there are not setup or anything like that in v3. A plugin is an npm package so all its dependencies are automatically installed when doing npm install plugin-name

Clarification for that means you need to move the dependencies into your main package.json and not the custom plugin one.

Got it.
But on developing phase, it would be handy if I can install local plugin’s dependencies through strapi-cli
Anyway, thank you all :slight_smile:

I still don’t understand what you mean about installing dependencies with strapi-cli ? why not make your app a monorepo so you can install dependencies in the plugins folder too ?

There is a feature called “Workspaces”, which helps you to setup multiple packages in such a way that you only need to run yarn install once to install all of them in a single pass.
To achieve this start using yarn instead of npm. As npm released workspaces just a few weeks ago for v7 (which is available with Node v15).

Add workspaces to the package.json, In your case your local plugins that are under development. Please note that "private": true property is mandatory when working with workspaces.

  "private": true,
  "workspaces": [

Now run yarn install, it will install all your packages from ./plugins/{plugin-name}/package.json. Also it will create a symlink for your plugin inside the node_modules:

Please note that after this Yarn will not allow you to add packages into the root packages.json, as it is expecting you to add them to Workspaces. To add a package to root packages.json please add the -W flag:

yarn add axios -W


This is exactly what I meant :grinning:

Thanks for your kind answer!

1 Like

Thank you so much sunnyson this was really helpful!
Should be added to the strapi docs for sure :slight_smile::+1:

this was super useful for me. Any chance this can be added to docs for plugin local development?

Definitely should be in the docs! Would have saved me 5 days of hell to know this :scream: :scream:


care to share your package.json with your local plugin so everyone can see how to set it up with Strapi V4.

EDIT here is answer, add this in your main strapi package.json

“workspaces”: [

EDIT2: your node version need to be 16 or higher for it to work.

"node":">=16.x.x <=18.x.x",

Do you have any idea for docker builds? Still cause error…

same here, docker builds fail

SOLUTION: Ok I solved it by adding plugin dependencies to the main package.json. I did not remove the old dependencies from the /src/plugins/myplugin/package.json, but I think you can. I do not use yarn workspaces. Adding the dependency was all I did and the plugin works without going into plugin directory and running npm install separately.

1 Like

thank you for sharing this solution with community.

my solution was insalling dependencies by manually.

here is my dockerfile;

FROM node:20
# alternatively you can use FROM strapi/base:latest

# Set up working directory

# Copy package.json to root directory
COPY package.json .

# Copy yarn.lock to root directory
COPY yarn.lock .

# Install dependencies, but not generate a yarn.lock file and fail if an update is needed
RUN yarn install --frozen-lockfile

# Copy strapi project files
COPY . .
# TODO: You should add new plugins here
RUN cd src/plugins/test-plugin && yarn install --frozen-lockfile

# Build admin panel
RUN yarn build

# Run on port 1337

# Start strapi server
CMD ["yarn", "start"]