'NoneType' object has no attribute 'ui_type' when running blender using CLI My code runs fine when I run the script directly in blender. However if run the file headless in the terminal I get this error and the animation renders the default cube instead of my animation:
'NoneType' object has no attribute 'ui_type'

Here is my CLI command:
'/Applications/Blender.app/Contents/MacOS/Blender -b /Users/myname/Desktop/folder/videoRender.blend -a&quot;

Blender text editor code:
import bpy, sys, os

bpy.context.area.ui_type = 'SEQUENCE_EDITOR'

#create image sequences and import screens of there are more than one file
if (len(files) == 1):
    
    # set duration to 300
    duration = 300
    
    for index in range(5):
        filesFolder = folder + &quot;/&quot; + str((index+1)) + '/renderedFiles/'
        bpy.ops.sequencer.image_strip_add(
            directory=filesFolder, 
            files=files[1], 
            show_multiview=False,
            frame_start= (filesCount * index), 
            frame_end=filesCount * index, 
            channel=5
        )
Thanks to @batFINGER, his solution to ditch the operator worked! Here's the answer: Simple python script to stitch images into movie failing with incorrect context.