tikfav icon indicating copy to clipboard operation
tikfav copied to clipboard

SyntaxError when run with Node 22+ because of the removed `assert` syntax

Open peterwooley opened this issue 7 months ago • 0 comments

Hey! Thanks for this tool. It's nice to know I won't lose these TikTok videos like I did with Vine.

I ran into an issue using the latest version of Node (22.4.1). It looks like they removed the assert usage for importing packages starting in Node 22.0. I believe assert can just be replaced with with.

/path/to/npm/node_modules/tikfav/index.js:12
import packageInfo 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:439:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:445:30)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)

Node.js v22.4.1

When I ran the script on Node 20.15.1, it worked like a charm, so hopefully this just requires a keyword change.

peterwooley avatar Jul 10 '24 16:07 peterwooley