Trouble Building Plugin in `storage/plugins` for NocoBase v1.6.24 (Docker) - 404 for `dist/client/index.js` & Build Loop

Hello NocoBase Community,

I’m developing a new plugin, let’s call it Custom Plugin 1, for NocoBase v1.6.24 (Sometimes I use v1.6.25). I’m running NocoBase using the official Docker image (registry.cn-shanghai.aliyuncs.com/nocobase/nocobase:latest, which currently pulls v1.6.24). My plugin is located in the storage/plugins/ directory as an “independent plugin”.

The Core Problem:
When NocoBase loads, the browser attempts to fetch my plugin’s client-side code from:
http://localhost:13001/static/plugins/Custom Plugin 1/dist/client/index.js?version=0.1.0 (Note: actual path uses the real plugin directory name, not “Custom Plugin 1” with spaces)
This results in a 404 (Not Found) error, followed by a RequireJS “Script error for ‘Custom Plugin 1’”.

This 404 occurs even if I change the nocobase.client path in my plugin’s package.json, indicating NocoBase has a fixed expectation for this dist/client/index.js path for plugins in storage/plugins.

Attempts to Build the Plugin:
I understand that plugins in storage/plugins likely need to be compiled. I’ve tried various methods to build the plugin inside the running Docker container using @nocobase/cli (which is version 1.6.24 in my plugin’s devDependencies), but I’m encountering a persistent loop:

  1. Command Used (from /app/nocobase in container, using the actual directory name of my plugin):
    # Example, where 'my-actual-plugin-dir-name' is the directory name for Custom Plugin 1
    npx @nocobase/cli build storage/plugins/my-actual-plugin-dir-name 
    
  2. Result:
    The command outputs:
    Please install all dependencies
    $ yarn install
    
    (Sometimes followed by npm update notices).

Running yarn install or even yarn nocobase install in /app/nocobase completes (the latter shows “app installed successfully [v1.6.24]”), but immediately re-running the build command yields the same “Please install all dependencies” message. No dist directory is ever created in my plugin’s client folder.

I’ve also tried running the build command from within the plugin’s directory (/app/nocobase/storage/plugins/my-actual-plugin-dir-name) with commands like npx @nocobase/cli build or npx @nocobase/cli plugin build, with similar lack of success or dependency errors.

Plugin Structure & Files:

  • Location: D:\MyWorkspace\NocoBaseProject\storage\plugins\my-actual-plugin-dir-name\ (mounted into the container at /app/nocobase/storage/plugins/my-actual-plugin-dir-name)

  • storage/plugins/my-actual-plugin-dir-name/package.json:

    {
      "name": "custom-plugin-1", // This is the logical name, directory name might differ
      "version": "0.1.0",
      "main": "server/index.js",
      "nocobase": {
        "client": "client/index.js" // Also tried "client/dist/index.js" - server still requests from /dist/
      },
      "dependencies": {
        "@nocobase/database": "1.6.24",
        "@nocobase/server": "1.6.24",
        "@nocobase/client": "1.6.24",
        "@nocobase/utils": "1.6.24"
      },
      "devDependencies": {
        "@nocobase/cli": "1.6.24",
        "@nocobase/test": "1.6.24",
        "typescript": "^5.0.0"
      },
      "peerDependencies": {
        "@nocobase/database": "1.6.24",
        "@nocobase/server": "1.6.24",
        "@nocobase/client": "1.6.24",
        "@nocobase/utils": "1.6.24"
      }
    }
    
  • storage/plugins/my-actual-plugin-dir-name/server/index.js:

    const { Plugin } = require('@nocobase/server');
    
    class CustomPlugin1Server extends Plugin { // Renamed class for example
      async load() {
        console.log('Custom Plugin 1 server plugin LOAD CALLED - CLASS BASED');
      }
    }
    
    module.exports = CustomPlugin1Server;
    
  • storage/plugins/my-actual-plugin-dir-name/client/index.js (current state, ES Module):

    import { Plugin } from '@nocobase/client';
    
    class CustomPlugin1Client extends Plugin { // Renamed class for example
      async load() {
        console.log('Custom Plugin 1 client plugin LOAD CALLED - CLASS BASED');
      }
    }
    
    export default CustomPlugin1Client;
    

Docker Setup:

  • docker-compose.yml:
    version: "3" # Note: I know 'version' is obsolete, will remove
    
    networks:
      nocobase:
        driver: bridge
    
    services:
      nocobase-development:
        container_name: nocobase-development
        image: registry.cn-shanghai.aliyuncs.com/nocobase/nocobase:latest # This is v1.6.24
        networks:
          - nocobase
        depends_on:
          - postgres
        environment:
          - APP_KEY=your-secret-key
          - DB_DIALECT=postgres
          - DB_HOST=postgres
          - DB_DATABASE=nocobase
          - DB_USER=nocobase
          - DB_PASSWORD=nocobase
          - TZ=Asia/Shanghai
        volumes:
          # Example: ./my-nocobase-project/storage:/app/nocobase/storage 
          - ./storage:/app/nocobase/storage # Assumes your local 'storage' dir is correctly mapped
        ports:
          - "13001:80" # Port changed from 13000 due to conflict
    
      postgres:
        image: registry.cn-shanghai.aliyuncs.com/nocobase/postgres:16
        restart: always
        command: postgres -c wal_level=logical
        environment:
          POSTGRES_USER: nocobase
          POSTGRES_DB: nocobase
          POSTGRES_PASSWORD: nocobase
        volumes:
          # Example: ./my-nocobase-project/db/postgres:/var/lib/postgresql/data
          - ./storage/db/postgres:/var/lib/postgresql/data # Assumes your local db data path
        networks:
          - nocobase
    

Questions for the Community:

  1. What is the correct and definitive procedure for building the client-side code (i.e., creating the client/dist/index.js) for a plugin located in storage/plugins when using NocoBase v1.6.24 with the official Docker image? (My plugin’s actual directory name is Custom Plugin 1, but I’m referring to it as Custom Plugin 1 in this post).
  2. Why might the @nocobase/cli build command be stuck in the “Please install all dependencies $ yarn install” loop, even after yarn install and yarn nocobase install have been run in the container’s /app/nocobase directory? Is there a specific environment variable, path configuration, or user context required for this command to work correctly within the Docker image for storage/plugins?
  3. Are there any known issues or specific configurations needed for the nocobase/nocobase:latest (v1.6.24) Docker image concerning the development and building of local plugins in storage/plugins?
  4. Does the nocobase.client field in package.json actually influence the runtime path for plugins in storage/plugins, or is client/dist/index.js always assumed by the server?

Any guidance, examples, or pointers to relevant documentation for v1.6.x would be greatly appreciated! I’m trying to establish a smooth development workflow for this plugin.

Thanks in advance!

Thanks for providing the detailed information. However, developing and packaging plugins directly inside a Docker container is not recommended, as the image may lack certain dependencies required for development. It’s better to use the source code directly or set up your environment with create-nocobase-app.