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 '?' #488

Closed
frakkio opened this issue Feb 14, 2022 · 12 comments
Closed

SyntaxError: Unexpected token '?' #488

frakkio opened this issue Feb 14, 2022 · 12 comments

Comments

@frakkio
Copy link

frakkio commented Feb 14, 2022

I'm trying to add @nuxt/image to my project using yarn node version is v12.22.1, nuxt version 2.15.8
and I got these errors:

ERROR  [@nuxt/image] ipx is an optional dependency for local image optimization and is not properly installed. 
Please try npm install or yarn install again.
FATAL  SyntaxError: Unexpected token '?'
 at node_modules/@nuxt/image/dist/module.js:130:13
 at async Object.ipxSetup [as setup] (node_modules/@nuxt/image/dist/module.js:128:48)
 at async ModuleContainer.imageModule2 (node_modules/@nuxt/image/dist/module.js:270:7)
 at async ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:239:20)
 at async ModuleContainer.ready (node_modules/@nuxt/core/dist/core.js:55:5)
 at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:478:5)

  │   ✖ Nuxt Fatal Error                         
  │
  │   Error: SyntaxError: Unexpected token '?'   

error Command failed with exit code 1.

I've also tried to add ipx with the same results

@stmoerman
Copy link

stmoerman commented Feb 16, 2022

Same issue here on nuxt 2.15.7 and node v16.13.0 - not sure why it's requiring this dependency or not properly installing it.

For now I found that downgrading @nuxt/image to 0.6.0 fixed this for me.

@comfuture
Copy link

same here.
It works properly on @nuxt/image@0.6.0, and ipx@0.9.1.
npm audit fix command will upgrade @nuxt/image to 0.6.1 so be careful.

@Tragio
Copy link
Contributor

Tragio commented Feb 23, 2022

I have the same problem, but not happening locally, only when building on Vercel. Downgrading from 0.6.2 to 0.6.0 fixed the problem.

@memotux
Copy link

memotux commented Mar 3, 2022

Confirm issue @nuxt/image@0.6.2.

Downgrading to @nuxt/image@0.6.0 work.

@weotch
Copy link

weotch commented Apr 26, 2022

Had this issue when deploying to Netlify using --target=static on 0.6.2. Switching to 0.6.0 worked for me as well.

@kezek
Copy link

kezek commented May 3, 2022

Having the same issue.

@snakemastr
Copy link

Same, breaks on production build because we use npm audit fix in our build process.
I am not sure what the correct solution is here, probably will create the responsive images manually as there are not as much yet..

Is this problem caused by Nuxt 2 dragging its feet towards Nuxt 3 and therefore unable to fully support optional chaining (probably due to outdated packages like webpack 4)?

@speker2010
Copy link

speker2010 commented Jun 16, 2022

This error caused by using ?? in ipx: https://github.com/unjs/ipx/blob/9296aa2e0fb376f8f18824f1306a9998b8a39a98/src/utils.ts#L4

If I replace ?? with ||, the error occurs in (reqOptions?):
https://github.com/unjs/ipx/blob/9296aa2e0fb376f8f18824f1306a9998b8a39a98/src/sources/http.ts#L27

Nuxt runs without errors, if I remove the optional operator.

@speker2010
Copy link

speker2010 commented Jun 16, 2022

Updating node v12 to v14 helped me

@pi0
Copy link
Member

pi0 commented Jun 22, 2022

Please use Node.js >= 14 (16 LTS)

@pi0 pi0 closed this as completed Jun 22, 2022
@kumaresaninfo
Copy link

Same error i am getting, after node js version upgrade

Node Version :- v18.19.1

Screenshot 2024-02-20 at 9 06 18 PM

I need solution

@hieult-hybrid-technologies

Same error i am getting, after node js version upgrade

Node Version :- v18.19.1

Screenshot 2024-02-20 at 9 06 18 PM I need solution

did u fixed?

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