Skip to content

SyntaxError: Unexpected identifier 'assert' in Node 22 LTS #144

@gillisandrew

Description

@gillisandrew

Describe the bug
Code will fail to run in Node 22 LTS with the following error:

import WorkflowSchema from "../workflow-v1.0.json" assert { type: "json" };
                                                   ^^^^^^

SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:340:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:102:18)
    at #translate (node:internal/modules/esm/loader:433:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:480:27)

Node.js v22.11.0

This is the relevant line in the source:

import WorkflowSchema from "../workflow-v1.0.json" assert {type: "json"};

Package/Area

  • Expressions
  • Workflow Parser
  • Language Service
  • Language Server

Package Version
@actions/[email protected]

Additional context
This is related to Node dropping support for the non-standard assert syntax (see nodejs/node#52104)
I only checked with Workflow Parser but a search shows it will also impact Language Service

import descriptions from "./descriptions.json" assert {type: "json"};

import workflow_call from "./workflow_call.json" assert {type: "json"};

import schemaImport from "rest-api-description/descriptions/api.github.com/dereferenced/api.github.com.deref.json" assert {type: "json"};

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions