react-diagrams icon indicating copy to clipboard operation
react-diagrams copied to clipboard

Issue with npm start - Unexpected token

Open tushartk opened this issue 9 years ago • 4 comments

Hi, I have included this in my project's package.json and did an npm install. Everything went fine, but when i do an npm start, i get the following issue:

Module parse failed: <project-location>\project-react\node_modules\storm-react-diagrams\src\defaults\DefaultLinkFactory.ts Unexpected token (14:34)
You may need an appropriate loader to handle this file type.
|       }
|
|       generateReactWidget(diagramEngine: DiagramEngine, link: LinkModel): JSX.Element {
|               return React.createElement(DefaultLinkWidget, {
|                       link: link,

What do you think might be the issue ?

tushartk avatar Sep 21 '17 06:09 tushartk

It seems that you don't use TypeScript in your project.

In that case proper way to include entities is through the package main like this

import {
  DiagramEngine,
  DefaultNodeFactory,
  DefaultLinkFactory,
  DiagramModel,
  DefaultNodeModel,
  LinkModel,
  DefaultPortModel,
  DiagramWidget,
  PointModel
} from "storm-react-diagrams";

Note: Copy wisely, pick only classes that you need

JokerNN avatar Sep 21 '17 10:09 JokerNN

Just a clarification, i do use Typescript though.

tushartk avatar Sep 21 '17 10:09 tushartk

@tushartk ok, have you tried posted example? It is still correct way to do thing you want.

The reason your import doesn't work for you - most possibly webpack misconfiguration which prevents typescript loader to be used on node_modules. And it is OK because I believe it's not easy way to use this library

JokerNN avatar Sep 21 '17 11:09 JokerNN

The posted example does work. Although even i guessed it might be an issue with the Typescript loaders when importing it in a project. Thanks anyway @JokerNN

tushartk avatar Sep 22 '17 03:09 tushartk