strapi-plugin-fcm icon indicating copy to clipboard operation
strapi-plugin-fcm copied to clipboard

Resolving Module Path Issues in Strapi: Adapting Plugin Code for Strapi Version 4.14.4

Open Simoneplataniafutureait opened this issue 2 years ago • 7 comments

In the current version of Strapi (4.14.4), there is no lib folder inside the @strapi/strapi module, and I had to manually change the path (services files of the server folder) in the plugin module to "dist."

NEW: const { getPaginationInfo, convertPagedToStartLimit, shouldCount, transformPaginationResponse, } = require('@strapi/strapi/dist/core-api/service/pagination');

const { getFetchParams } = require('@strapi/strapi/dist/core-api/service');

OLD: const { getPaginationInfo, convertPagedToStartLimit, shouldCount, transformPaginationResponse, } = require('@strapi/strapi/lib/core-api/service/pagination');

const { getFetchParams } = require('@strapi/strapi/lib/core-api/service');

In my configuration, I'm using Yarn, and the server stopped with this error displayed on the console:

$ strapi develop Error: Could not load js config file /var/www/vhosts/zen-chaplygin.62-138-11-62.plesk.page/httpdocs/node_modules/strapi-plugin-fcm/strapi-server.js: Cannot find module '@strapi/strapi/lib/core-api/service/pagination'

In the end, I managed to fix it temporarily with the solution above, but I don't know much about Strapi's structure, and I'm not sure if this could be helpful. However, I wanted to issue a warning about this.

Simoneplataniafutureait avatar Oct 16 '23 13:10 Simoneplataniafutureait

facing the same issue.

vasuchawla avatar Dec 28 '23 10:12 vasuchawla

facing the same error. tried to fix with your solution but didn't work. any other way?

ericdmoraes avatar Jan 08 '24 13:01 ericdmoraes

Hi ..

Yeah this is now a blocker Same error even after making the changes from lib to dist

Error: Could not load js config file /mnt/appdata/app/stata/node_modules/strapi-plugin-fcm/strapi-server.js: Package subpath './dist/core-api/service/pagination' is not defined by ││ "exports" in /mnt/appdata/app/stata/node_modules/@strapi/strapi/package.json ││ at loadJsFile (/mnt/appdata/app/stata/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:18:13) ││ at Module.loadFile (/mnt/appdata/app/stata/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:37:14) ││ at Object.loadPlugins (/mnt/appdata/app/stata/node_modules/@strapi/strapi/dist/core/loaders/plugins/index.js:90:41) ││ at async Strapi.loadPlugins (/mnt/appdata/app/stata/node_modules/@strapi/strapi/dist/Strapi.js:311:5) ││ at async Promise.all (index 3) ││ at async Strapi.register (/mnt/appdata/app/stata/node_modules/@strapi/strapi/dist/Strapi.js:341:5) ││ at async Strapi.load (/mnt/appdata/app/stata/node_modules/@strapi/strapi/dist/Strapi.js:425:5) ││ at async Object.develop (/mnt/appdata/app/stata/node_modules/@strapi/admin/dist/_chunks/index-sNH2VWbC.js:837:28) ││ at async develop (/mnt/appdata/app/stata/node_modules/@strapi/admin/dist/_chunks/develop-YNTGWKMC.js:61:5) ││ at async Command.parseAsync (/mnt/appdata/app/stata/node_modules/commander/lib/command.js:923:5)

jamesnyika avatar Feb 04 '24 01:02 jamesnyika

@jamesnyika I am also getting the same error did you get any solution?

Prashant4900 avatar Feb 17 '24 13:02 Prashant4900

Hi @jamesnyika, fixed on my fork https://github.com/marcogermani87/strapi-plugin-fcm (working with strapi v4.24.3):

npm i https://github.com/marcogermani87/strapi-plugin-fcm

marcogermani87 avatar May 26 '24 19:05 marcogermani87

@marcogermani87 Thanks for this it worked for me! Could you make a PR with your changes and hopefully @itisnajim can merge it to the main plugin.

dkhan99 avatar Oct 02 '24 02:10 dkhan99

Hi @itisnajim. Can you give a solution for this? Please "@strapi/strapi": "4.25.17",

│   Error: Could not load js config file /home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/strapi-plugin-fcm/strapi-server.js: Package subpath './lib/core-api/service' is not defined by "exports" in    │
│   /home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/package.json                                                                                                                         │
│   at loadJsFile (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:18:13)                                                                │
│   at Module.loadFile (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/dist/core/app-configuration/load-config-file.js:37:14)                                                           │
│   at Object.loadPlugins (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/dist/core/loaders/plugins/index.js:90:41)                                                                     │
│   at async Strapi.loadPlugins (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/dist/Strapi.js:311:5)                                                                                   │
│   at async Promise.all (index 3)                                                                                                                                                                                         │
│   at async Strapi.register (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/dist/Strapi.js:341:5)                                                                                      │
│   at async Strapi.load (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/strapi/dist/Strapi.js:425:5)                                                                                          │
│   at async Object.develop (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/admin/dist/_chunks/index-sNH2VWbC.js:837:28)                                                                       │
│   at async develop (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/@strapi/admin/dist/_chunks/develop-YNTGWKMC.js:61:5)                                                                              │
│   at async Command.parseAsync (/home/admin/web/strapi.walaxia.cat/public_html/strapi/node_modules/commander/lib/command.js:923:5)      

IvanWala avatar Dec 19 '24 12:12 IvanWala