Unable to programmatically create user
The exceptions aren't caused from the code shown in the question. The second exception is caused from the following code in ContentEntityBase::getTranslatedField().

// Populate $this-&gt;fields to speed-up further look-ups and to keep track of
// fields objects, possibly holding changes to field values.
if (!isset($this-&gt;fields[$name][$langcode])) {
  $definition = $this-&gt;getFieldDefinition($name);
  if (!$definition) {
    throw new \InvalidArgumentException("Field $name is unknown."); // Line 586.
  }

  // Omissis.

}


There is a module that is trying to access the type field, which doesn't exist for the User entity.

Your code is correct. Eventually, instead of setting the user fields using a setter method, you could use the array User::create() accepts as first parameter, which uses the following array keys (among others):


name
mail
pass
status
roles (an array)
langcode
preferred_langcode
preferred_admin_langcode


There isn't an equivalent value for enforceIsNew(), so you need to call that method on the created user object.