aspen-cloud/triplit

SyntaxError: Unexpected identifier 'assert'

tkoop opened this issue · 3 comments

While trying to run the Triplit server, using the "run.js" file, I get this error:

$ node run.js 
file:///var/www/triplit/node_modules/@triplit/server/dist/server.js:14
import pjson 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)

Node.js v22.4.1

My run.js file is the standard code provided:

import { createServer } from '@triplit/server';
 
const port = +(process.env.PORT || 8080);
 
const startServer = createServer({
  storage: 'sqlite',
  verboseLogs: true,
});
 
const dbServer = startServer(port);
 
console.log('running on port', port);
process.on('SIGINT', function () {
  dbServer.close(() => {
    console.log('Shutting down server... ');
    process.exit();
  });
});

I'm using the latest Node (version 22.4.1). In my package.json, I have "type" set to "json".

What's wrong?

Hi @tkoop we're taking a look here

The quick fix is to use a node version <22 e.g. nvm use 20. And we'll look into a fix to be node 22 compatible.

Hi @tkoop the latest @triplit/server 0.3.63 should be node 22 compatible. Closing for now, but if you run into other issues let us know.