How do we include js and css dependencies in Sage 9?

So, I do the following and I’m getting an error

$ yarn add smooth-scroll

Then in resources/assets/scripts/routes/common.js, on the first line, I have:

import ‘smooth-scroll’;

Under finalize(), I have:

finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
var scroll = new SmoothScroll(‘a[href*=“#”]’);
},

When I yarn build, I get the following error:

error Command failed with exit code 2.
info Visit yarn run | Yarn for documentation about this command.

I run yarn run lint:scripts and it tells me the following:

/var/www/website.com/wordpress/wp-content/themes/websitetheme/resources/assets/scripts/routes/common.js
9:9 error ‘scroll’ is assigned a value but never used no-unused-vars
9:22 error ‘SmoothScroll’ is not defined no-undef

This leads me to believe the Smooth Scroll script is not loading.

As reference, this is the Smooth Scroll documentation: https://github.com/cferdinandi/smooth-scroll

I’ve tried the “proper” way that the official documentation states and that doesn’t work either.

I’m wondering if anyone has any idea what’s wrong?

I can’t just download the Smooth Scroll JS file and place it in my assets/scripts folder and enqueue it in setup, because ESlint throws back all sorts of errors.

Should I just enqueue the CDN and create/enqueue a JS file and place this code in it?:

var scroll = new SmoothScroll(‘a[href*=“#”]’);