Failed to build plugin that generate by strapi generate with typescript

System Information
  • Strapi Version: 4.12.5
  • Operating System: macOS Ventura 13.0
  • Database: postgres
  • Node Version: 18.17.1
  • NPM Version: 8.19.4
  • Yarn Version: 1.22.19

Hi everyone, I created a Strapi project using npx create-strapi-app@latestand then dockerize it using strapi-community/dockerize.

And I generated a plugin by strapi generate with typescript. I yarn at the plugin directory and built the dist folder, when I got back to the project root and tried yarn build, there are several errors showed up

[
  {
    file: './src/plugins/content-type-custom-fields/admin/src/components/Initializer/index.tsx',
    message: "TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/pluginId.ts' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
    stack: "Error: TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/pluginId.ts' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
  },
  {
    file: './src/plugins/content-type-custom-fields/admin/src/index.tsx',
    message: "TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/package.json' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
    stack: "Error: TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/package.json' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
  },
  {
    file: './src/plugins/content-type-custom-fields/admin/src/index.tsx',
    message: "TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/components/Initializer/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
    stack: "Error: TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/components/Initializer/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
  },
  {
    file: './src/plugins/content-type-custom-fields/admin/src/index.tsx',
    message: "TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/components/PluginIcon/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
    stack: "Error: TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/components/PluginIcon/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
  },
  {
    file: './src/plugins/content-type-custom-fields/admin/src/index.tsx',
    message: "TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/pages/App/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
    stack: "Error: TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/pages/App/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
  },
  {
    file: './src/plugins/content-type-custom-fields/admin/src/pages/App/index.tsx',
    message: "TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/pages/HomePage/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
    stack: "Error: TS6059: File '/Users/username/Documents/project-dir/src/plugins/content-type-custom-fields/admin/src/pages/HomePage/index.tsx' is not under 'rootDir' '/Users/username/Documents/project-dir/src/admin'. 'rootDir' is expected to contain all source files.\n" +
  }
]

Does anyone know why this happens and how to fix this?

Sorry, anyone know what’s happening?