How to get node object from node ID in a drupal 8 custom module, how do I get a node object if I have the node id?
I tried : 

$node = new Node($nid);
$node-&gt;save();`


but got this error:


  Argument 1 passed to
  Drupal\Core\Entity\ContentEntityBase::__construct() must be of the
  type array, string given,
There are a few ways.

If your context allows for Dependency injection, inject the entity_type.manager service and use it like so:

$node = $this-&gt;entityTypeManager-&gt;getStorage('node')-&gt;load($nid);


If not you can still use the entity_type.manager service:

$node = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load($nid);


If you prefer, you can use the Node class directly:

$node = \Drupal\node\Entity\Node::load($nid);