Uncaught SyntaxError: expected expression, got '<'

I did so and with a basic config, yeap, things are working fine :slight_smile:

…but one of the reasons that I couldn’t upgrade some time ago to the major version 6 is this error Plugin error after upgrading Bud to ^6.3.5

You can also check my whole bud config on this thread starter.

And if I try to upgrade it to 6.5.3, then on the VS Code I get an on each bud instance, eg .entry({... that says:

any
Property 'entry' does not exist on type 'Bud'

and on the browser after running the dev:

Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/chalk/source/index.js from /Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/node_modules/@babel/highlight/lib/index.js not supported.
Instead change the require of /Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/chalk/source/index.js in /Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/node_modules/@babel/highlight/lib/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/node_modules/@babel/highlight/lib/index.js:14:14)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/node_modules/@babel/code-frame/lib/index.js:9:18)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/lib/path/replacement.js:13:18)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/lib/path/index.js:28:28)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/lib/context.js:8:13)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/lib/traverse-node.js:8:16)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/traverse/lib/index.js:34:21)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/helper-replace-supers/lib/index.js:20:17)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/helper-create-class-features-plugin/lib/fields.js:13:28)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/helper-create-class-features-plugin/lib/index.js:32:15)
    at Object.<anonymous> (/Users/erip2/Documents/local-theme.com/dev/public/app/themes/local-theme/node_modules/@babel/plugin-proposal-class-properties/lib/index.js:10:40)
    at async Promise.all (index 0)
    js app.js:1066

See the v6 upgrade guide:

What does your package.json look like? Are you including your own import of babel? If you are importing babel it is on you to keep that dependency up-to-date.

What do you need to do in order to share your repository as a reproduction case? This is the only way forward in order to help you. There is something wrong in your project but it is never going to be debugged with Discourse as a devtool. @ me when you have a minimal reproduction and I’ll be glad to take another look.

Ok, finally I managed to fix this :partying_face:

I managed to upgrade to version 6 and fix my issues.

About this:

I removed the // @ts-check on top the bud.config.mjs file.

And about this:

I just deleted my node_modules folder and ran yarn again and this error didn’t show up.

About the other topic I referred here, I am not sure how that was fixed, but I would suggest others take a good look at the function chain in the bud config.

Thanks, guys!

Both of these errors:

Property 'entry' does not exist on type 'Bud'

and

Type 'import("project/node_modules/webpack/types").Compiler' 
is not assignable to type
'import("~/Library/Caches/typescript/4.7/node_modules/webpack/types").Compiler'

are related in that they are not actual runtime errors, they are Problems flagged by vscode’s static analysis. In the case of the second error you can see that the problem is with some stale cache vscode is pulling from ~/Library/Caches/typescript/4.7 not matching the type described by node_modules/webpack/types. bud.js obviously has no control over that mismatch.

For more information on vscode type acquisition and type checking:

Also worth looking at the vscode docs on jsconfig.json. This file gives you a lot of control over this and many other things you’ll likely one day encounter working with JS in your project. Totally worth configuring:

Anyway, removing//@ts-enable will “fix” both of these issues, but they were never going to cause your project to not build. You could add //@ts-enable back and it won’t cause any problems aside from adding noise to the editor.

You could also add //@ts-ignore above the line that is emitting the problem if you wanted to keep the typechecking everywhere else. Maybe try to remove the ignore the next time you update, maybe the error will have resolved itself. I think the value added from the //@ts-enable intellisense makes it worth figuring out how to keep it. But, whatever works for you.

Glad you’re all sorted out.

1 Like