With Godot4 Script the one-liner doesn't work anymore, as you'd write:
@export_node_path @onready var target_node=get_node(target_node)
which produces these errors:
Could not resolve member "target_node": Cyclic reference.
"@export_node_path" annotation requires a variable of type "NodePath" but type "Node" was given instead.
The "@onready" annotation will make the default value to be set after the "@export" takes effect and will override it. (Warning treated as error.)
So you'll have to write 2 lines:
@export_node_path var target_node
@onready var _target_node = get_node(target_node)