The error “Module not found: Can’t resolve ‘@angular/cdk/scrolling'” in Javascript is an error that is not difficult to fix. To solve this error, we need to use some command run in your terminal in your root directory to load the @angular/cdk package in npm.

## Why does the error “Module not found: Can’t resolve ‘@angular/cdk/scrolling'” in Javascript?

The error “Module not found: Can’t resolve ‘@angular/cdk/scrolling'” in Javascript is thrown when you forget to install package @angular/cdk in your program. From there, it throws the above error. Luckily the error I want to fix is ​​not complex in the next section. Here are some of the ways I often use when encountering this problem.

The error message occurs as follows:

Module not found: Error: Can't resolve '@angular/cdk/scrolling'

## How to fix this error?

### Case 1: Accessing the style attribute of an element null

To fix this error, we need to ensure that our program has installed the @angular/cdk package in package.json. To install the @angular/cdk package, we will execute the install syntax in the terminal of your root directory to download that package.

Syntax:

npm install <package>

Example:

npm install @angular/cdk --save

Similar:

npm i @angular/cdk --save

In the statement above, your program has finished adding the @angular/cdk package to the program.

If the error does not disappear, try restarting the program and using the “npm update” command. The error will most likely disappear, and your program will usually work.

If, at this time, your program still throws the above error, then try the following way to reinstall npm to solve this error.

### Case 2: Reinstalling npm

Before reinstalling npm, make sure to delete node_modules and package-lock.json files. Its command is as follows:

rm -rf node_modules
rm -f package-lock.json

After deleting node_modules and package-lock.json files, we clean the npm cache and reinstall npm.

npm cache clean --force

REM Reinstall npm
npm install

After running the following command lines and your program still shows an error, please check if @angular/cdk is in the dependencies object. Then restart the IDE you are using to write the program.

If you use VS code to build your program, then in some cases, you can restart it, and your program will run normally.