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.
npm install <package>
npm install @angular/cdk --save
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.
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
Name of the university: UTC