Check if product with sku exists in Magento 2

try {
    $product = $productRepository->get($sku);
} catch (\Magento\Framework\Exception\NoSuchEntityException $e){
    $product = false;
}

Try this:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Catalog\Model\Product');

if($product->getIdBySku($sku)) {
    echo 'exit';    
}

OR

protected $product;
    public function __construct(
            \Magento\Catalog\Model\Product $product
    ) {
        $this->_product = $product;
    }

and after check

if($this->_product->getIdBySku($sku)) {
    echo 'exit';    
}

Tags:

Magento2