Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Strapi v5 Typescript create plugin not finding types #62

Open
tomh4 opened this issue Oct 10, 2024 · 3 comments
Open

[bug]: Strapi v5 Typescript create plugin not finding types #62

tomh4 opened this issue Oct 10, 2024 · 3 comments
Labels
issue: bug Issue reporting a bug severity: high If it breaks the basic use of the product status: can not reproduce Not enough information to reproduce status: pending reproduction Waiting for free time to reproduce the issue, or more information

Comments

@tomh4
Copy link

tomh4 commented Oct 10, 2024

What version of @strapi/sdk-plugin are you using?

  • npm version: 10.5.0
  • Node version: v18.20.2
  • Strapi Version: 5.0.2
  • Plugin version: 5.2.6

What's Wrong?

When trying to create a new plugin with strapi 5 and typescript, strapi can no longer be started if plugin is used inside strapi.
While creating the plugin the following warnings appear:

[18:40:34.406] [0] $ npm install
[18:41:32.113] [0]   npm WARN ERESOLVE overriding peer dependency
[18:41:32.114] [0]   npm WARN While resolving: [email protected]
[18:41:32.114] [0]   npm WARN Found: [email protected]
[18:41:32.114] [0]   npm WARN node_modules/@strapi/admin/node_modules/typescript
[18:41:32.114] [0]   npm WARN   typescript@"5.3.2" from @strapi/[email protected]
[18:41:32.114] [0]   npm WARN   node_modules/@strapi/admin
[18:41:32.115] [0]   npm WARN     @strapi/admin@"5.0.4" from @strapi/[email protected]
[18:41:32.115] [0]   npm WARN     node_modules/@strapi/strapi
[18:41:32.115] [0]   npm WARN     8 more (@strapi/content-manager, @strapi/content-releases, ...)
[18:41:32.116] [0]   npm WARN   1 more (react-intl)
[18:41:32.116] [0]   npm WARN 
[18:41:32.116] [0]   npm WARN Could not resolve dependency:
[18:41:32.116] [0]   npm WARN peerOptional typescript@">= 4.4.x <= 5.2.x" from [email protected]
[18:41:32.116] [0]   npm WARN node_modules/@strapi/admin/node_modules/msw
[18:41:32.116] [0]   npm WARN   msw@"1.3.0" from @strapi/[email protected]
[18:41:32.116] [0]   npm WARN   node_modules/@strapi/admin
[18:41:32.116] [0]   npm WARN 
[18:41:32.116] [0]   npm WARN Conflicting peer dependency: [email protected]
[18:41:32.116] [0]   npm WARN node_modules/typescript
[18:41:32.117] [0]   npm WARN   peerOptional typescript@">= 4.4.x <= 5.2.x" from [email protected]
[18:41:32.117] [0]   npm WARN   node_modules/@strapi/admin/node_modules/msw
[18:41:32.117] [0]   npm WARN     msw@"1.3.0" from @strapi/[email protected]
[18:41:32.117] [0]   npm WARN     node_modules/@strapi/admin

when starting the app the following error appears:

plugins/new-plugin/admin/src/pages/App.tsx:1:22 - error TS2307: Cannot find module '@strapi/strapi/admin' or its corresponding type declarations.

1 import { Page } from '@strapi/strapi/admin';

To Reproduce

  • Create a new Strapi project with Typescript
  • Create a new plugin inside the Strapi project : npx @strapi/sdk-plugin init plugins/new-plugin
  • Say Y to everything
  • Add the plugin to the config file as told by the instructions:
[INFO] 
You can now enable your plugin by adding the following in ./config/plugins.ts
────────────────────────────────────────────
export default {
  // ...
  'generate-recipe': {
    enabled: true,
    resolve: 'plugins/new-plugin'
  },
  // ...
}
  • run npm run develop

Expected Behaviour

App loads

@tomh4 tomh4 added the issue: bug Issue reporting a bug label Oct 10, 2024
@innerdvations innerdvations added the severity: medium If it breaks the basic use of the product but can be worked around label Nov 28, 2024
@maccomaccomaccomacco maccomaccomaccomacco added severity: high If it breaks the basic use of the product and removed severity: medium If it breaks the basic use of the product but can be worked around labels Dec 4, 2024
@obafunmiso-olufemi
Copy link

Any solution to this ?
facing same issue

@jhoward1994
Copy link
Contributor

jhoward1994 commented Jan 21, 2025

Hi, thanks for submitting the issue! I wasn't able to recreate this exactly. Please could you try the following:

  • Ensure the plugin is created at the path ./src/plugins/PLUGIN_NAME in you project
  • If using as a local plugin, enable it as follows in config/plugins.ts (replacing the path and plugin name with yours)
export default () => ({
  "new-plugin": {
    enabled: true,
    resolve: "./src/plugins/new-plugin",
  },
});

Here I am using Strapi v5.8.0 and sdk-plugin v5.3.0 and following these steps I was able to navigate to /admin/plugins/new-plugin in the browser with no issues.

@jhoward1994 jhoward1994 added the status: pending reproduction Waiting for free time to reproduce the issue, or more information label Jan 21, 2025
@github-project-automation github-project-automation bot moved this to To be reviewed (Open) in Developer Experience Squad Jan 22, 2025
@hanpaine hanpaine moved this from To be reviewed (Open) to In progress in Developer Experience Squad Jan 22, 2025
@hanpaine hanpaine added the status: can not reproduce Not enough information to reproduce label Jan 27, 2025
Copy link
Contributor

This is a templated message

Hello @tomh4,

Thank you for reporting this bug, however we are unable to reproduce the issue you described given the information we have on hand. Can you please create a fresh project that you are able to reproduce the issue in, provide clear steps to reproduce this issue, and either upload this fresh project to a new GitHub repo or compress it into a .zip and upload it on this issue?

We would greatly appreciate your assistance with this, by working in a fresh project it will cut out any possible variables that might be unrelated.
Please note that issues labeled with status: can not reproduce will be closed in 14 days if there is no activity.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug severity: high If it breaks the basic use of the product status: can not reproduce Not enough information to reproduce status: pending reproduction Waiting for free time to reproduce the issue, or more information
Projects
Status: In progress
Development

No branches or pull requests

6 participants