annotorious: Error: \node_modules\@recogito\annotorious\src\index.js: Unexpected token (47:6)
Hi,
The demo example on this (https://www.npmjs.com/package/@recogito/annotorious) and the github page worked fine when using simple index and js files with “python -m http.server” but I was then planing for the big project.
I developed whole backend in Node.js using this library but now when I implemented it in React.js by the method that is written in the same pages as the following steps
- npm i @recogito/annotorious
- import { Annotorious } from ‘@recogito/annotorious’;
- const anno = new Annotorious({ image: ‘annotoriousLabels’ });
but It produces error on step no. 2 (import), below is the error picture
And the component file in which I’m including it is as following:
`import React from “react”; // @material-ui/core components import { makeStyles } from “@material-ui/core/styles”; // core components import GridItem from “components/Grid/GridItem.js”; import GridContainer from “components/Grid/GridContainer.js”; import Button from “components/CustomButtons/Button.js”; import Card from “components/Card/Card.js”; import CardHeader from “components/Card/CardHeader.js”; import CardBody from “components/Card/CardBody.js”; import CardFooter from “components/Card/CardFooter.js”;
import { Annotorious } from ‘@recogito/annotorious’;
import { apiURL } from ‘…/…/…/config’; // import an from ‘./annotorious’;
const styles = { cardCategoryWhite: { color: “rgba(255,255,255,.62)”, margin: “0”, fontSize: “14px”, marginTop: “0”, marginBottom: “0” }, cardTitleWhite: { color: “#FFFFFF”, marginTop: “0px”, minHeight: “auto”, fontWeight: “300”, fontFamily: “‘Roboto’, ‘Helvetica’, ‘Arial’, sans-serif”, marginBottom: “3px”, textDecoration: “none” } };
const useStyles = makeStyles(styles);
const ImageCard = (props) => { const classes = useStyles();
const anno = new Annotorious({ image: ‘annotoriousLabels’ });
return ( <div> <GridContainer> <GridItem xs={12} sm={12} md={12}> <Card> <CardHeader color="primary">
Picture
Please label the picture below.
</CardHeader> <CardBody> <img className = “annotatable” id = “annotoriousLabels” src = {apiURL + ‘/’ + props.photo.url} alt = “To be labelled…” width = ‘100%’ height = ‘100%’ /> </CardBody> <CardFooter> <Button color="success">Save Changes</Button> </CardFooter> </Card> </GridItem> </GridContainer> </div> ); }export default ImageCard; `
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (8 by maintainers)
Commits related to this issue
- Merge branch '#24-multiple-targers-selection' into #365-annotorious-lib-multiple-targets — committed to oleksandr-danylchenko/annotorious by oleksandr-danylchenko 5 months ago
- Merge branch '#24-multiple-targers-selection' into #365-annotorious-lib-multiple-targets — committed to oleksandr-danylchenko/annotorious by oleksandr-danylchenko 5 months ago
THANK YOU very much sir…
the url problem I solved by requesting the backend… and that’s what I needed… and appyTemplate is what I needed… now this library is perfect for me…
thanks… for your time to help me…
hi! a little late to the party.
@rsimon: yes, you should be able to refer to the source files of the package via
import { ... } from '@recogito/annotorious/src
. themain
field of the package manifest only resolves the default import when no path is suffixed.if you aim to expose the react source, i’d recommend exporting the styles separately as a CSS ubndle instead of relying on webpack to bundle them within source react components (e.g.,
import './styles.css'
). this should allow folks to roll their own methods for loading the styles (e.g.,import '@recogito/annotorious/dist/style.css'
or directly via<link>
tags).do you have any idea why annotorious fails with
create-react-app
(CRA)?@Usman55555:
this looks like JS linter warnings to me instead of proper parsing errors; so nothing wrong here per se. i think rainer explained it well in the above comment (use the global
window.Annotorious
instead of ES6 imports from the pre-built bundle).