Skip to content

Migrate from import assertion to import attribution #11

Open

Description

@codmajik

Package version

1.5.0

Describe the bug

NodeJS v22 dropped import assertion completely according to NodeJS docs, this was deprecated on v18.20 and completely dropped in v22.
image

Due to this, running the upgrade kit on anything above v21 will cause a syntax error as show in the screenshot
image

Reproduction repo

No response

Activity

  1. RomainLanz commented on Sep 2, 2024

    @RomainLanz
    Member

    Hey @codmajik! 👋🏻

    I am not sure I understand the table correctly, does that mean we can freely use the with syntax in older Node.js versions?

  2. self-assigned this
    on Sep 2, 2024
  3. guledali commented on Sep 26, 2024

    @guledali

    I'm getting this as well

    Node.js v22.3.0

  4. dmazoli commented on Sep 29, 2024

    @dmazoli

    Same here, trying to run upgrade-kit at an adonis 5.8.0 project.

    `
    npx @adonisjs/upgrade-kit upgrade-packages --path={{pathToProject}}
    file:///usr/local/lib/node_modules/@adonisjs/upgrade-kit/node_modules/@adonisjs/ace/build/src/helpers.js:3
    import schema from '../schemas/command_metadata_schema.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:436:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:30)

    Node.js v22.7.0
    `

  5. zakariamehbi commented on Oct 2, 2024

    @zakariamehbi

    Working like a charm with the LTS version of node.

  6. CodeSyncr commented on Nov 11, 2024

    @CodeSyncr

    +1

    file:///Users/yashkumar/.npm/_npx/632aa895c0dbb5b6/node_modules/@adonisjs/ace/build/src/helpers.js:3
    import schema from '../schemas/command_metadata_schema.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)

    Using Latest LTS v22.11.0
    
  7. CodeSyncr commented on Nov 11, 2024

    @CodeSyncr

    Temporary solution would be nvm use 21

  8. motephyr commented on Jan 20, 2025

    @motephyr

    I changed the code

    import schema from '../ schemas/command_metadata_schema.jon' assert {type:'json’};
    

    to

    const schema = JSON.parse(await readFile(new URL('../schemas/command_metadata_schema.json', import.meta.url)));
    

    skip the warning.

  9. leocabeza commented on Jun 26, 2025

    @leocabeza

    Can anyone share what node version worked for you to bypass this error?

    Edit: for future self and others: I switched from yarn to pnpm and fixed this issue

  10. motephyr commented on Jun 27, 2025

    @motephyr

    I use Node.js v22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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