strapi-community / strapi-plugin-slugify

A plugin for Strapi Headless CMS that provides the ability to auto slugify a field for any content type.
https://market.strapi.io/plugins/strapi-plugin-slugify
MIT License
45 stars 21 forks source link

strapi 4.14.0: no npm run develop compatibility with v.2.3.4 of strapi-plugin-slugify #108

Closed pgsfredda closed 1 year ago

pgsfredda commented 1 year ago

System configuration

Describe the problem

Installing strapi v.4.14.0, the npm run develop command fail with a blocking error message in the log. Uninstalling strapi-plugin-slugify plugin, strapi works fine again.

Error log

Error: Could not load js config file .../server/node_modules/strapi-plugin-slugify/strapi-server.js: Cannot find module '@strapi/strapi/lib/core-api/controller/transform'
Require stack:
- .../server/node_modules/strapi-plugin-slugify/server/controllers/slug-controller.js
- .../server/node_modules/strapi-plugin-slugify/server/controllers/index.js
- .../server/node_modules/strapi-plugin-slugify/server/index.js
- .../server/node_modules/strapi-plugin-slugify/strapi-server.js
- .../server/node_modules/@strapi/utils/dist/import-default.js
- .../server/node_modules/@strapi/utils/dist/index.js
- .../server/node_modules/@strapi/data-transfer/dist/utils/components.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/queries/entity.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/queries/index.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/providers/local-destination/strategies/restore/index.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/providers/local-destination/strategies/index.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/providers/local-destination/index.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/providers/index.js
- .../server/node_modules/@strapi/data-transfer/dist/strapi/index.js
- .../server/node_modules/@strapi/data-transfer/dist/index.js
- .../server/node_modules/@strapi/strapi/dist/commands/index.js
- .../server/node_modules/@strapi/strapi/bin/strapi.js
    at loadJsFile (.../server/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:21:19)
    at loadFile (.../server/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:41:20)
    at Object.loadPlugins (.../server/node_modules/@strapi/strapi/dist/core/loaders/plugins/index.js:93:62)
    at async Strapi.loadPlugins (.../server/node_modules/@strapi/strapi/dist/Strapi.js:373:9)
    at async Promise.all (index 3)
    at async Strapi.register (.../server/node_modules/@strapi/strapi/dist/Strapi.js:407:9)
    at async Strapi.load (.../server/node_modules/@strapi/strapi/dist/Strapi.js:493:9)
    at async workerProcess (.../server/node_modules/@strapi/strapi/dist/commands/actions/develop/action.js:100:28)
    at async exports.default (.../server/node_modules/@strapi/strapi/dist/commands/actions/develop/action.js:38:20)

Steps to reproduce the behavior

  1. change package.json with the new version of strapi
  2. invoke npm install command
  3. invoke npm run build command
  4. invoke npm run develop command

Additional context

package.json

{
  "name": "server",
  "private": true,
  "version": "1.0.0",
  "description": "description",
  "scripts": {
    "develop": "strapi develop",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi"
  },
  "dependencies": {
    "@strapi/plugin-i18n": "4.14.0",
    "@strapi/plugin-users-permissions": "4.14.0",
    "@strapi/provider-email-nodemailer": "^4.14.0",
    "@strapi/strapi": "4.14.0",
    "mysql2": "^3.6.1",
    "strapi-plugin-duplicate-button": "^1.1.13",
    "strapi-plugin-slugify": "^2.3.4"
  },
  "author": {
    "name": "a name"
  },
  "strapi": {
    "uuid": "xxx"
  },
  "engines": {
    "node": ">=14.19.1 <=18.x.x",
    "npm": ">=6.0.0"
  },
  "license": "license"
}

config/plugin.ts

//...

slugify: {
        enabled: true,
        config: {
            shouldUpdateSlug: true,
            contentTypes: {
                teacher: {
                    field: 'slug',
                    references: ['firstname', 'lastname'],
                },
                student: {
                    field: 'slug',
                    references: ['firstname', 'lastname', 'birthdate'],
                },
            },
        },
      },

//...
matepaiva commented 1 year ago

I had the same problem here.

the problem is in the file slug-controller: Cannot find module '@strapi/strapi/lib/core-api/controller/transform. (line 6).

ComfortablyCoding commented 1 year ago

Thanks for the report, this should be fixed in the latest version.

pgsfredda commented 1 year ago

thank you @ComfortablyCoding

ComfortablyCoding commented 1 year ago

Your welcome :)

BabyDino commented 11 months ago

With Strapi 4.15.4, I am facing the same error:

[ERROR]  There seems to be an unexpected error, try again with --debug for more information 

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                                                                          │
│   Error: Could not load js config file /home/xxx/dev/xxx-api/node_modules/strapi-plugin-slugify/strapi-server.js: Package subpath './dist/core-api/controller/transform' is not defined by "exports" in                  │
│   /home/xxx/dev/xxx-api/node_modules/@strapi/strapi/package.json                                                                                                                                                         │
...
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
boroco commented 11 months ago

@ComfortablyCoding Looks like this still hasn't been resolved. Node: v18.17.0 npm: 10.2.0 strapi: 4.14.4

Error: Could not load js config file ││ /Users/macos/code/testwebsite2022/test-strapi/node_modules/strapi-plugin-slugify/strapi-server.js: Package ││ subpath './dist/core-api/controller/transform' is not defined by "exports" in ││ /Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/package.json ││ at loadJsFile (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/dist/core/app-confi ││ guration/load-config-file.js:18:13) ││ at Module.loadFile (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/dist/core/app- ││ configuration/load-config-file.js:37:14) ││ at Object.loadPlugins (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/dist/core/l ││ oaders/plugins/index.js:90:41) ││ at async Strapi.loadPlugins ││ (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/dist/Strapi.js:304:5) ││ at async Promise.all (index 3) ││ at async Strapi.register ││ (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/dist/Strapi.js:334:5) ││ at async Strapi.load ││ (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/strapi/dist/Strapi.js:418:5) ││ at async Object.develop (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/admin/dist/_chun ││ ks/index-cce8ecb6.js:1160:28) ││ at async develop (/Users/macos/code/testwebsite2022/test-strapi/node_modules/@strapi/admin/dist/_chunks/deve ││ lop-69e28e61.js:52:5) ││ at async Command.parseAsync ││ (/Users/macos/code/testwebsite2022/test-strapi/node_modules/commander/lib/command.js:923:5)

ComfortablyCoding commented 11 months ago

Thanks for the update!

They must have changed the path again.

I will internalize the logic for this so it does not happen again.

boroco commented 11 months ago

Thank you, Hope this gets fixed quickly, I really needed it. :)

ComfortablyCoding commented 11 months ago

@BabyDino and @boroco This should now be (permanently) fixed in v2.3.7+