Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token, expected "}" #440

Open
crystalfp opened this issue Sep 20, 2024 · 3 comments
Open

SyntaxError: Unexpected token, expected "}" #440

crystalfp opened this issue Sep 20, 2024 · 3 comments

Comments

@crystalfp
Copy link

Running madge 8.0.0 this way:

madge --extensions ts,vue --ts-config tsconfig.json -i madge.png --warning src

Generates the following error:

✖ SyntaxError: Unexpected token, expected "}" (8:14)
    at constructor (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:349:19)
    at FlowParserMixin.raise (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:3247:19)
    at FlowParserMixin.unexpected (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:3267:16)
    at FlowParserMixin.expect (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:3577:12)
    at FlowParserMixin.jsxParseExpressionContainer (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:6675:10)
    at FlowParserMixin.jsxParseElementAt (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:6749:36)
    at FlowParserMixin.jsxParseElement (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:6787:17)
    at FlowParserMixin.parseExprAtom (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:6797:19)
    at FlowParserMixin.parseExprSubscripts (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:10562:23)
    at FlowParserMixin.parseUpdate (C:\Users\mvalle\AppData\Roaming\npm\node_modules\madge\node_modules\@babel\parser\lib\index.js:10547:21)

Really don't know what changed from my previous issue except node that is v22.5.1
Thanks for looking!
mario

@crystalfp
Copy link
Author

Strange. This happens only if I run a npm script launching madge. That is:

  "scripts": {
    "madge": "madge --extensions ts,vue --ts-config tsconfig.json -i madge.png --warning src"
}

Instead if I run from the commend prompt

madge --extensions ts,vue --ts-config tsconfig.json -i madge.png --warning src

or

npx madge --extensions ts,vue --ts-config tsconfig.json -i madge.png --warning src

Simply does not find any file as in #434

@Jassmin586
Copy link

Jassmin586 commented Sep 25, 2024

Same problem with ts and vue files. But I have a little bit different error.

Madge version: 8.0.0

SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>? (5:0)
    at constructor (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:362:19)
    at FlowParserMixin.raise (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:3260:19)
    at FlowParserMixin.jsxParseElementAt (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:6793:18)
    at FlowParserMixin.jsxParseElement (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:6800:17)
    at FlowParserMixin.parseExprAtom (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:6810:19)
    at FlowParserMixin.parseExprSubscripts (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:10584:23)
    at FlowParserMixin.parseUpdate (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:10569:21)
    at FlowParserMixin.parseMaybeUnary (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:10549:23)
    at FlowParserMixin.parseMaybeUnaryOrPrivate (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:10403:61)
    at FlowParserMixin.parseExprOps (/home/frontend/madge/node_modules/@babel/parser/lib/index.js:10408:23)

@crystalfp
Copy link
Author

@Jassmin586 Here a minimal reproduction. This happens when loading an element from the chart.js package. So, after installing this package create the Vue file zz.vue:

<script setup lang="ts">
import {Chart} from "chart.js";
</script>
<template>
</template>

then:

madge  --extensions ts,vue --ts-config tsconfig.json -i madge.png --warning zz.vue

Hope it helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants