This code was working fine.
I don't know if it's because I upgraded to Node 17 or what, but now I get
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]:
Module "file:///Users/xxxxx/code/projects/xxxxx/dist/server/data/countries.json"
needs an import assertion of type "json"
In my api.ts
I have:
import countryTable from './data/countries.json';
Here's how I start api.ts
which is used by server.ts
:
NODE_ENV=production node --optimize_for_size --trace-warnings --experimental-json-modules --no-warnings server/server.js
Update: According to the proposal, the new keyword is with
instead of assert
, but assert
is supposed to stay for compatibility reasons. The new code would look as follows:
import countryTable from "./data/countries.json" with { type: "json" };
You will need to use:
import countryTable from "./data/countries.json" assert { type: "json" };