go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.44k stars 5.52k forks source link

Module not found error when building v1.21 #30596

Closed pboguslawski closed 6 months ago

pboguslawski commented 7 months ago

Description

make build worked fine a few days before for same gitea source and now throws

+ make build
rm -rf public/assets/js public/assets/css public/assets/fonts public/assets/img/webpack
npx webpack
assets by status 20.3 MiB [cached] 163 assets

ERROR in ./node_modules/mermaid/dist/mindmap-definition-617cf8dd.js 4:0-56
Module not found: Error: Package path ./dist/cytoscape.umd.js is not exported from package /my/path/gitea-build/node_modules/cytoscape (see exports field in /my/path/gitea-build/node_modules/cytoscape/package.json)
 @ ./node_modules/mermaid/dist/mermaid-934d9bea.js 3535:38-80
 @ ./node_modules/mermaid/dist/mermaid.core.mjs
 @ ./web_src/js/markup/mermaid.js 34:39-37:5
 @ ./web_src/js/markup/content.js 1:0-45 7:2-15
 @ ./web_src/js/index.js 20:0-76 105:2-20 110:2-19

webpack 5.88.2 compiled with 1 error in 33361 ms

Similar problem described on https://github.com/langgenius/dify/issues/3613

Gitea Version

1.21

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Compiled from sources.

Database

MySQL/MariaDB

silverwind commented 7 months ago

Maybe your node_modules broke somehow, try running make clean-all and then retry make build.

If you want to investigate deeper, could also see if a npm i alone does any changes.

xiaoqingrong commented 7 months ago

I have the same problem. I use Apple mac M1。use docker build:docker buildx build --platform=linux/amd64 -t test/dify-web:v1.3.7 .,and cytoscape installed。bug have this errors

image
xiaoqingrong commented 7 months ago

I was fine before, but not lately

silverwind commented 7 months ago

Seems like upstream issue in that package: https://github.com/cytoscape/cytoscape.js/issues/3239

silverwind commented 7 months ago

What's strange is that v1.21 uses 3.26.0 while the issues are reported with 3.29.0.

wxiaoguang commented 7 months ago

I also occasionally experience the similar problem (not only related to cytoscape). I just do rm -rf node_modules and then make build, then everything goes well.

I think it is the npm/webpack's problem, for example, if there is a network error (or use ^C to stop the npm process), then the node_modules directory would go corrupted. Removing node_modules directory and restart the build, then no error.


On my side (macOS M2), I tried rm -rf node_modules && make build on 1.21 branch, it succeeds.

pboguslawski commented 7 months ago

Problem started to occur in automatic build process (empty node_modules, no network errors, etc.) and occurs every time. Build process and source code were not changed in the meantime.

The problem is caused by running make generate-images before make build (we use custom logo and favicon) and removing --no-package-lock from make generate-images in Makefile resolves this issue for us.

Please verify and fix.

silverwind commented 7 months ago

Hmm yeah make generate-images is somewhat of an oddball. Maybe we should just put those dependencies into package.json. At least the often-problematic canvas dependency is listed as optionalDependency so will not fail the whole install if it fails:

https://github.com/fabricjs/fabric.js/blob/c27a21883eda49b7a7bfcc32f49eb59a099a1536/package.json#L74

silverwind commented 7 months ago

On topic here: Let's wait on https://github.com/cytoscape/cytoscape.js/issues/3239 and a future mermaid.js update to resolve this hopefully.

silverwind commented 7 months ago

https://github.com/go-gitea/gitea/pull/30713 updates main branch to the fixed cytoscape version.

└─┬ mermaid@10.9.0
  ├─┬ cytoscape-cose-bilkent@4.1.0
  │ └── cytoscape@3.29.2 deduped
  └── cytoscape@3.29.2
yp05327 commented 6 months ago

Is this issue fixed after bump the version of dependencies?

silverwind commented 6 months ago

Pretty sure it should.