Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Module parse failed: Unexpected token. You may need an additional loader to handle the result of these loaders

When I import Attributes from ‘graphology-types’ in my .jsx file, I get this error

import { Attributes } from ‘graphology-types’

ERROR in ./node_modules/graphology-types/index.d.ts 11:5
Module parse failed: Unexpected token (11:5)
File was processed with these loaders:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • ./node_modules/source-map-loader/dist/cjs.js
    You may need an additional loader to handle the result of these loaders.
    | * Miscellaneous types.
    | */

type Attributes = {[name: string]: any};
|
| type GraphType = ‘mixed’ | ‘directed’ | ‘undirected’;

I am new in React. I think the problem is that the graphology-types/index.d.ts is a TypeScript file and I am using .jsx files. How can I make this work?

>Solution :

If you are not using TypeScript, you don’t need to import types in your code. Attributes is a TS type that has no meaning or purpose in JS code. You don’t need it. I suspect you may be copying TS examples into your code? If so, you can modify those to strip away the types.

Unless you want your app to be strongly typed, but that’s a decision you should make separate from encountering this, on its own merits.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading