Enqueuing wp_enqueue_media()
will fixed the [Error] TypeError: undefined is not an object (evaluating ‘wp.media.query’) error.
But you may still need to a plugin like ‘User role editor’, ‘User Access Manager’ to enable user access to the media library.