Melinda
Melinda

Reputation: 265

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:

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?

Upvotes: 0

Views: 961

Answers (1)

adsy
adsy

Reputation: 11587

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.

Upvotes: 0

Related Questions