Every time i run “yarn pm create @my-project/plugin-hello” i get the following output:
{"level":"error",
"message":"Cannot find plugin '@my-project/plugin-hello'",
"stack":"Error: Cannot find plugin '@my-project/plugin-hello\n
at PluginManager.getPackageJson (/app/nocobase/node_modules/@nocobase/server/lib/plugin-manager/plugin-manager.js:134:13)\n
at async _PluginManager.create (/app/nocobase/node_modules/@nocobase/server/lib/plugin-manager/plugin-manager.js:292:18)\n
at async _AppCommand.<anonymous> (/app/nocobase/node_modules/@nocobase/server/lib/commands/pm.js:39:5)\n
at async _AppCommand.parseAsync (/app/nocobase/node_modules/@nocobase/server/node_modules/commander/lib/command.js:935:5)\n
at async _AsyncEmitter.runAsCLI (/app/nocobase/node_modules/@nocobase/server/lib/application.js:541:23)",
"meta":{},"module":"application","submodule":"","method":"","app":"main","reqId":"fffa994e-9f37-4360-bed9-1b2cc94d6157","dataSourceKey":"main","timestamp":"2025-01-19 01:33:45"}
So i’ve looked into “/app/nocobase/node_modules/@nocobase/server/lib/plugin-manager/plugin-manager.js:134” and it looks like the code is expecting the plugin to be inside the “node_modules” folder instead of “packages/plugin”, that is the path where yarn places the new plugin folder.
I tried hard coding the path to “packages/plugin” in plugin-manager.js but it was unsuccessful.
Also tried older releases of Nocobase, nothing changed.
@caio-ra
I’m facing the exact same issue when trying to create a custom plugin following the tutorial. I get the same error about the plugin not being found in node_modules.
@imantung
I tried your suggestion to run yarn build before yarn start, and even used yarn dev, but unfortunately, the issue persists.
Hi there, I encountered the same problem when using the Docker-installed version of NocoBase. And I guess you use this version too. Here is my solution.
Check why it cannot find the plugin.
I looked into the plugin-manager.js file and found the getPackageJson function. I added an output for the packageFile parameter when it encountered an error. I discovered that NocoBase was looking for the plugin in /app/nocobase/node_modules/@my-project/plugin-hello, but the created folder was actually in /app/nocobase/packages/plugins/@my-project/plugin-hello.
Move file to node_modules
Because of the wrong folder, NocoBase could not find the new plugin. One way to solve this problem is to copy /app/nocobase/packages/plugins/@my-project/plugin-hello to /app/nocobase/node_modules/@my-project/plugin-hello. Alternatively, you can create a symbolic link:
Then try to create a new plugin; it should work now.
I guess this is a problem that only appears in the Docker installation version. @leandro-jm might be using the source code or Git installation, which is why they did not reproduce the issue.
I have two environment of nocobase, both are same versions: Developer (local) and Test (docker).
Developer(Local), i use for developing, tests, debugging and build the plugin. For this version i use the command install (yarn create nocobase-app)
Test (Docker), i use for final test, in this case i export plugin version Local in file .tar and import in Nocobase Docker version. For this version i use the docker compose.