Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Looks like multiple versions of prosemirror-model were loaded #445

Closed
ThePaulMcBride opened this issue Nov 18, 2022 · 4 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@ThePaulMcBride
Copy link
Collaborator

Description
I'm having an issues with @hocuspocus/transformer. I am giving a valid minimal schema with valid content but I'm getting errors about duplicate imports of prosemirror-model.

Steps to reproduce the bug
I've created a little sandbox app, heres the link: https://replit.com/@ThePaulMcBride/HocuspocusTransformerError#index.js

Just run the app and you'll see the issues.

Expected behavior
It should return a yjs doc

Screenshot, video, or GIF
Screenshot 2022-11-18 at 15 40 48

Additional context
This seems like it has been mentioned before, but the issue has been closed on the TipTap repo despite ongoing conversation.

ueberdosis/tiptap#577

@janthurau
Copy link
Collaborator

hey @ThePaulMcBride, thanks for the report and especially for the replit :)

I think this is caused by the transformer including @tiptap/starter-kit, which includes a few tiptap deps which then include prosemirror directly (not using peerDep).

Linking ueberdosis/tiptap#3209, which I've raised with the team.

Refs #417

@zanemcca
Copy link
Collaborator

zanemcca commented Dec 8, 2022

I will just add this detail here because it is likely to be relevant for others who run into this problem. Webpack can be a bit dumb sometimes and it might end up building your app with both an esm and cjs copy of some prosemirror, yjs or tiptap library. These will also act like duplicate packages and there is no possible resolution with npm.

If you do face this problem your best friend will be webpack aliases which can be used to force usage of either esm or cjs. I am unsure about solutions for other build systems.

@ThePaulMcBride
Copy link
Collaborator Author

I've update this demo to the latest versions of Tiptap and Hocuspocus, but the error is idential. I'm also pretty sure it doesn't use a bundler at all. What would the fix be for this?

https://replit.com/@ThePaulMcBride/HocuspocusTransformerError

@zanemcca
Copy link
Collaborator

zanemcca commented Dec 9, 2022

@ThePaulMcBride I wrote this script for myself to find duplicate prosemirror packages in the npm modules.

#!/bin/bash

duplicate_packages=`npm ls -s --parseable --all | grep -v @types | sed 's:.*/::' | grep prosemirror  | sort | uniq -d`

echo
if [ -z "$duplicate_packages" ]
then
    echo "No duplicate prosemirror packages found!"
    echo
else
    echo "Duplicate prosemirror packages were found!"
    full_package_paths=`npm ls --parseable --long $duplicate_packages`
    for package in $duplicate_packages
    do
        echo
        echo $package
        echo "$full_package_paths" | grep $package | sort -r
    done
    echo
    exit 1
fi

I believe the newest release of tiptap should be using peerDependencies now so you should be able to manually install the specific versions of the packages that you want. You should also use --prefer-dedupe when installing packages and you may also find it beneficial to purge your package-lock.json and node_modules to do a fresh install.

If you are not using npm workspaces to manage your project then you will likely be able to resolve any remaining issues with npm overrides.

If the script comes up clean and you still run into issues then it is likely an esm/cjs issue which would require a build system solution like the webpack aliases I referred to earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants