I am trying to run an angular 4 application but i keep getting this error
ERROR in Could not resolve module @angular/core
There are no other errors. No dependency errors nothing. @angular/core exists in the node_modules folder. I have tried with @angular/cli installed and without but no effect on this error. I am not sure how to resolve this. It occurs in my amazon ec2 machine but not in my local Mac machine. The versions of the libraries are all the same.
Any help will be appreciated. Thanks.
Solution 1: Delete node_modules folder and run npm install But our local Angular application will have older versions of packages installed in node_modules folder. So delete the node_modules folder manually from the application directory. After that clear the cache using npm cache clean --verify .
To solve the error "Cannot find module '@angular/core'", make sure you have installed all dependencies by running the npm install command, set the baseUrl option to src in your tsconfig. json file and restart your IDE and development server.
To fix Unable to resolve dependency tree error in Angular while installing npm packages follow the below steps. Run npm install --save --legacy-peer-deps instead of npm install command. Another way is delete node_modules folder and package_lock.
If anyone still facing such issue-
Your package.json may have been corrupt. Follow the below steps:
Clean/clear the cache. To clear the cache, run the below command.
npm cache clean --force
Install angular/core library again (specific version of your application).
npm i @angular/core
npm install
What may cause such issue is caused by an incorrect TypeScript configuration.
Make sure your tsconfig.json has moduleResolution
set to "node"
(rather than e.g. "classic"
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With