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 identifier 'assert' when using Node.js v22.0.0+ with ultracite #148

Open
101sam opened this issue Dec 29, 2024 · 0 comments

Comments

@101sam
Copy link

101sam commented Dec 29, 2024

SyntaxError: Unexpected identifier 'assert' when using Node.js v22.0.0+ with ultracite

Description

When running npx ultracite with Node.js v22.0.0 and above, the following error is thrown:

file:///Users/ABCD/TEST//node_modules/.pnpm/[email protected]/node_modules/ultracite/scripts/run.mjs:5
import packageJson from '../package.json' assert { type: 'json' };
                                          ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
    at callTranslator (node:internal/modules/esm/loader:416:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)
    at async link (node:internal/modules/esm/module_job:88:21)

Node.js v22.0.0

The same command works fine with earlier versions of Node.js (e.g., v18.x or v20.x or v21.x).


Steps to Reproduce

  1. Install Node.js v22.0.0 (or any version >= v22.0.0).
  2. Run the following command:
    npx ultracite
  3. Observe the error.

Expected Behavior

The npx ultracite command should run successfully without throwing a syntax error.


Actual Behavior

The command fails with a SyntaxError: Unexpected identifier 'assert' when attempting to import package.json using the assert { type: 'json' } syntax.


Environment

  • Node.js Version: v22.0.0
  • ultracite Version: 4.1.14
  • Operating System: macOS/Windows/Linux (mention your OS here)
========================================================
Date..............: 2024-12-29 05:32:14 PST 
Installed Global Packages: 
nvm       : 0.40.1
node      : v22.0.0
npm       : 10.5.1
Node.js : v22.0.0
yarn       :  
pnpm     : 9.15.0
bun        : Not installed
corepack  : 0.26.0
pm2       : 5.4.3

=== System Information ===
Hostname: 123.internal
OS: Darwin
Kernel Version: 24.2.0
Processor: arm
CPU Architecture: arm64
Memory: 184.734 GB
Disk Space: 1.3Ti
========================================================

Additional Information

  • The error seems to be related to the assert { type: 'json' } syntax used in the run.mjs file of the ultracite package.
  • This syntax works in Node.js v16.14.0 and above for most versions but appears to break in Node.js v22.0.0+.
  • The issue might be related to changes in the ECMAScript Module (ESM) implementation in Node.js v22.0.0.

Similar issues were encountered when attempting to use the GitHub repository:
next-forge

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

1 participant