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

fix deprecated import assertion #441

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Azarattum
Copy link
Contributor

import something from "somewhere" assert { type: "json" }; has been deprecated in favour of import something from "somewhere" with { type: "json" };. Therefore on the latest node versions (tested on 22.2.0 and 22.3.0) the library just doesn't install:

import pkg 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:164:18)
    at callTranslator (node:internal/modules/esm/loader:429:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:435:30)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)

Node.js v22.3.0

This is a simple fix that changes assert to with in nodejs-install-helper.js.

NodeJS Docs

https://nodejs.org/docs/v20.15.0/api/esm.html#import-attributes

This feature was previously named "Import assertions", and using the assert keyword instead of with. Any uses in code of the prior assert keyword should be updated to use with instead.

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

Successfully merging this pull request may close these issues.

None yet

1 participant