"Fatal error: Call to a member function setFormClass()"
The code shown in the question doesn't correctly bootstrap Drupal. An external script needs to do that, differently from a module. While loading the autoloader allows PHP to find the Node class, that isn't sufficient to bootstrap Drupal correctly.
I usually use the authenticate.php file as guideline for writing code for an external script file that needs to bootstrap Drupal.
use Drupal\Core\DrupalKernel;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\node\NodeInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Route;

// Change the directory to the Drupal root.
// Edit the following line to make it point to the directory containing the autoload.php file.
chdir('.');
$autoloader = (require_once 'autoload.php');

try {
  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $kernel-&gt;boot();

  // A route is required for route matching.
  $request-&gt;attributes-&gt;set(RouteObjectInterface::ROUTE_OBJECT, new Route('&lt;none&gt;'));
  $request-&gt;attributes-&gt;set(RouteObjectInterface::ROUTE_NAME, '&lt;none&gt;');
  $kernel-&gt;preHandle($request);

  // Ensure our request includes the session if appropriate.
  if (PHP_SAPI !== 'cli') {
    $request-&gt;setSession($kernel-&gt;getContainer()-&gt;get('session'));
  }
} catch (HttpExceptionInterface $e) {
  $response = new Response('', $e-&gt;getStatusCode());
  $response-&gt;prepare($request)-&gt;send();
  exit;
}

\Drupal::moduleHandler()-&gt;addModule('system', 'core/modules/system');
\Drupal::moduleHandler()-&gt;addModule('node', 'core/modules/node');
\Drupal::moduleHandler()-&gt;load('system');
\Drupal::moduleHandler()-&gt;load('node');

$node = Node::load(123);
$node-&gt;set('field_number', 222);
$node-&gt;save();

Actually, $kernel-&gt;preHandle($request) should be sufficient to load all the modules, since it contains the following code.
// Load all enabled modules.
$this-&gt;container-&gt;get('module_handler')-&gt;loadAll(); 

The code that explicitly loads the modules isn't necessary. At the same time, not explicitly loading the modules makes the code dependent from the installation profile, as the previous code line only loads the modules the installation profile enabled.