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.
Summary
Above are some ways to fix the error “Module not found: Error: Can’t resolve ‘@angular/cdk/scrolling’“. Please use the above methods for your article. I hope this article helps you and your program. Good luck.
Maybe you are interested:
- TypeError: $(…).slick is not a function in jQuery
- Use map() on an Array in Reverse Order in JavaScript
- “TypeError: Cannot read Property ‘0’ of Undefined” in JavaScript

My name is Tom Joseph, and I work as a software engineer. I enjoy programming and passing on my experience. C, C++, JAVA, and Python are my strong programming languages that I can share with everyone. In addition, I have also developed projects using Javascript, html, css.
Job: Developer
Name of the university: UTC
Programming Languages: C, C++, Javascript, JAVA, python, html, css