projectstorm / react-diagrams

a super simple, no-nonsense diagramming library written in react that just works
https://projectstorm.cloud/react-diagrams
MIT License
8.69k stars 1.17k forks source link

Unusual Error - "'@projectstorm/react-canvas-core' should be listed in the project's dependencies" #779

Closed gwsounddsg closed 3 years ago

gwsounddsg commented 3 years ago

TLDR;

Built the Getting Started project. Running yarn start produces the following error:

'@projectstorm/react-canvas-core' should be listed in the project's dependencies. Run 'npm i -S @projectstorm/react-canvas-core' to add it import/no-extraneous-dependencies

Steps that got me here

  1. Created a react app with npx create-react-app app-name --template typescript
  2. Downgraded react to use v16.14.0
  3. Added eslint with typescript support
  4. yarn add @projectstorm/react-diagrams
  5. installed peer dependences outlined in the Getting Started
  6. Started showing the error here. Found #765, and followed the steps of installing the "@next" version of react-diagrams. Also downgraded @emotion/core and @emotion/react to use version 10 instead of 11.
  7. yarn start = Error '@projectstorm/react-canvas-core' should be listed in the project's dependencies and tried running yarn add @projectstorm/react-canvas-core even though it was already installed but not listed in package.json under dependencies.
  8. 'yarn start' Error persists.

Note

I saw in issue #506 basically the same error. It's pointing to the line import { CanvasWidget } from "@projectstorm/react-canvas-core";.

ruy-c commented 3 years ago

Had pretty much the same issues but after hard digging I could solve it. Here the dependencies which worked for me:

"@emotion/core": "10.1.1",
"@emotion/react": "10.0.0",
"@emotion/styled": "10.0.0",
"@projectstorm/react-canvas-core": "6.3.0",
"@projectstorm/react-diagrams": "6.3.0",
"closest": "0.0.1",
"dagre": "0.8.5",
"pathfinding": "0.4.18",
"paths-js": "0.4.11",
"resize-observer-polyfill": "1.5.1",
gwsounddsg commented 3 years ago

So, oddly enough, after getting this error for a while I came back the next day and it just started working without me changing anything. I'm wondering if there was just a ts compiler error and I needed to restart VS Code.