Import referenced nodes to database using osm2pgsql

I have a Postgresql database where I want to store nodes that make up ways with highway tags (and nodes with highway tag) - I need the nodes to add elevation to them.
I have an OSM file that I filter over: osmium tags-filter luxembourg-latest.osm.pbf nwr/highway -o highway.osm
Then I tried running: osm2pgsql -d testing -P 5433 --output=flex -S styles/highways.lua highway.osm
where highway.lua is just basic script that is supposed to process all nodes:

local srid = 4326
local tables = {}
-- define table nodes:
tables.nodes = osm2pgsql.define_node_table('nodes', {
    -- not_null = true: if invalid node, ignore it
    { column = 'geom', type = 'point', projection=srid, not_null = true },
    { column = 'tags', type = 'jsonb' },
function osm2pgsql.process_node(object)
        geom = object:as_point(),
        tags = object.tags,

But this doesn’t work, it only imports nodes that have highway tag (for Luxembourg it stores 49112 nodes from original 879254 nodes).
Is there something I’m missing in osm2pgsql or it’s just not possible?

Usually osm2pgsql will not call the process_node function for untagged nodes. You need to use the -x, --extra-attributes option to enabled that.

But in your case I suggest you a different approach: Add a process_way function and import the ways as LineStrings. They also contain all the node locations and you can add the elevation data there. It depends on what you want to achieve in the end, of course, whether that’s a better approach.