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 'with' #230

Open
brusooo opened this issue Jul 18, 2024 · 2 comments
Open

SyntaxError: Unexpected token 'with' #230

brusooo opened this issue Jul 18, 2024 · 2 comments

Comments

@brusooo
Copy link

brusooo commented Jul 18, 2024

Describe the bug

Hi there,

I'm encountering an error when running npx unlighthouse --site http://localhost:3000 for my Nuxt.js app. The error message is

file:///C:/Users/userName/AppData/Local/npm-cache/_npx/944eljfcbfwrdfffb/node_modules/cli-boxes/index.js:1
import cliBoxes from './boxes.json' with {type: 'json'};
                                    ^^^^

SyntaxError: Unexpected token 'with'
    at DefaultModuleLoader.moduleStrategy (node:internal/modules/esm/translators:116:18)
    at DefaultModuleLoader.moduleProvider (node:internal/modules/esm/loader:190:14)

Node.js v20.5.1

To resolve it, I modified the import statement in index.js from

import cliBoxes from './boxes.json' with {type: 'json'};

to

import cliBoxes from './boxes.json' assert {type: 'json'};

This change fixed the issue. I'm using Node.js version 20.5.1. I couldn't find any related information online, so I wanted to report this here.

Reproduction

No response

System / Nuxt Info

No response

@adarshmaharjan
Copy link

I am also having the same issue in node 18

npx unlighthouse --site https://jyothikrishna.vercel.app
`file:///home/adarsh/.nvm/versions/node/v18.18.2/lib/node_modules/unlighthouse/node_modules/cli-boxes/index.js:1

import cliBoxes from './boxes.json' with {type: 'json'};
                                    ^^^^

SyntaxError: Unexpected token 'with'
    at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)

Node.js v18.18.2
```

@rezamajidi
Copy link

For now, I recommend using the 0.13.0 version.

npx unlighthouse@0.13.0 --site https://jyothikrishna.vercel.app

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

3 participants