strapi/strapi

strapi build fails on updated dependency with V4.8.1

hypnotoad08 opened this issue · 14 comments

Bug report

Required System information

  • Node.js version: v16.19.1
  • NPM version: 8.19.3
  • Strapi version: 4.8.1
  • Database: MySQL
  • Operating system: windows/cent os 7
  • Is your project Javascript or Typescript: Javascript

Describe the bug

when attempting to do an npm build after updating to v4.8.1 I receive the following error on Webpack building dependencies step about a not exported package from a dependency.

Steps to reproduce the behavior

  1. Update package.json
    "@strapi/plugin-i18n": "4.8.1",
    "@strapi/plugin-users-permissions": "4.8.1",
    "@strapi/strapi": "4.8.1",
  2. npm install
  3. npm run build
  4. See error

Expected behavior

A successful build.

Screenshots

Webpack █████████████████████████ building (64%) 1/1 entries 9486/9622 dependencies 2214/2773 modules 264 active
esbuild-loader › .cache/admin/src/content-manager/pages/App/utils/getContentTypeLinks.js

ModuleNotFoundError: Module not found: Error: Package path ./addon/display/placeholder is not exported from package serverpath/node_modules/codemirror

Code snippets

If applicable, add code samples to help explain your problem.

Additional context

Add any other context about the problem here.

Faced the same issue

I would do the following steps (this incl. updating the strapi deps):

  • delete build, .cache & node_modules folders
  • change your strapi deps to the version you want to upgrade to e.g. 4.8.1
  • run npm install
  • run npm build

I would expect that to work. IF it doesn't then you should look at doing all the steps again, but also delete your lock file e.g. yarn.lock.

Same issue here. Deleted all folders + lock file, same result.

Same issue here. Deleted all folders + lock file, same result.

can you run the following commands? npm ls codemirror5 npm ls codemirror. I'd expect something like this:

strapi@ /Users/josh/code/strapi
└─┬ @strapi/admin@4.8.1 -> ./packages/core/admin
  └── codemirror5@npm:codemirror@5.65.11
strapi@ /Users/josh/code/strapi
└─┬ @strapi/admin@4.8.1 -> ./packages/core/admin
  └─┬ @strapi/design-system@1.6.5
    └─┬ @uiw/react-codemirror@4.19.9
      └── codemirror@6.0.1
└─┬ @strapi/strapi@4.8.1
  └─┬ @strapi/admin@4.8.1
    └── codemirror5@npm:codemirror@5.65.12
└─┬ @strapi/plugin-i18n@4.8.1
  └─┬ @strapi/design-system@1.6.5
    └─┬ @uiw/react-codemirror@4.19.9
      └── codemirror@6.0.1

I can only assuming something is caching somewhere for you all, those deps above are as expected but your admin src files are trying to look at importing from codemirror however this does not exist in the 4.8.0+ anymore as they should all be importing from codemirror5. If anyone can provide a reproduction repo of the issue that would be beneficial.

I can only assuming something is caching somewhere for you all, those deps above are as expected but your admin src files are trying to look at importing from codemirror however this does not exist in the 4.8.0+ anymore as they should all be importing from codemirror5. If anyone can provide a reproduction repo of the issue that would be beneficial.

I moved everything to a new repo and deleted build, .cache, npm_modules, and package-lock.json. Was able to reproduce it.

here is a reproduction repo - https://github.com/hypnotoad08/Strapi-test

thank you for this @hypnotoad08, I'll take a look as soon as I can!

Hey @hypnotoad08, the issue is with the plugin strapi-plugin-comments, they've used dependencies in their plugin in this case codemirror but they've not declared it in their package.json so the plugin is using our version which is v6 which has breaking changes. So realistically, the plugin author needs to double check all deps they've used are declared in their package.json to avoid this happening in the future. Because it's on the marketplace, i'll see if I can arrange them to be reached to that way as well.

This could be the case for any of you IMO. The easiest way to find out (or at least how i did it) remove a plugin one by one until the issue stops to isolate the plugin and check their source for missing dependencies, in particular codemirror.

Hey @hypnotoad08, the issue is with the plugin strapi-plugin-comments, they've used dependencies in their plugin in this case codemirror but they've not declared it in their package.json so the plugin is using our version which is v6 which has breaking changes. So realistically, the plugin author needs to double check all deps they've used are declared in their package.json to avoid this happening in the future. Because it's on the marketplace, i'll see if I can arrange them to be reached to that way as well.

This could be the case for any of you IMO. The easiest way to find out (or at least how i did it) remove a plugin one by one until the issue stops to isolate the plugin and check their source for missing dependencies, in particular codemirror.

Thank you for looking into this, I should have thought of checking plugins.

Issue fixed in strapi-plugin-comments@2.2.9 (release) and caused by our copy of Editor.js (Strapi WYSIWYG) where codemirror is used + indeed lack of strictly declared dependency.

BTW. Would be nice to expose the whole configurable WYSIWYG Editor to the Design System, what you think Strapi?

Issue fixed in strapi-plugin-comments@2.2.9 (release) and caused by our copy of Editor.js (Strapi WYSIWYG) where codemirror is used + indeed lack of strictly declared dependency.

BTW. Would be nice to expose the whole configurable WYSIWYG Editor to the Design System, what you think Strapi?

We expose most of our other inputs so it's not unreasonable, would you be able to open a new issue and tag me? I can get some internal feedback before I confirm.

@joshuaellis feature request created: https://feedback.strapi.io/feature-requests/p/expose-strapi-wysiwyg-to-design-system

It's not a bug so I decided to raise request by proper way.

Delete the following folders :

  • build
  • .cache
  • node_modules
    and folder : package-lock.json

Run commands : "npm install" or "yarn" then "npm run develop" if you're still getting an error related to module, try locating that module and delete the folder and run "npm run develop" again