itisnajim / strapi-plugin-fcm

Send FCM notifications from your Strapi app.
MIT License
23 stars 15 forks source link

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

Open Simoneplataniafutureait opened 1 year ago

Simoneplataniafutureait commented 1 year ago

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.

vasuchawla commented 10 months ago

facing the same issue.

ericdmoraes commented 10 months ago

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

jamesnyika commented 9 months ago

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)

Prashant4900 commented 8 months ago

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

marcogermani87 commented 5 months ago

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
dkhan99 commented 1 month ago

@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.