Ionic storage-angular error: Can’t resolve ‘@angular/common’ in storage-angular/fesm
I’m trying to use ionic/storage-angular in my ionic application. I was following the documentation: https://github.com/ionic-team/ionic-storage.
I installed storage-angular (npm install @ionic/storage-angular) but I'm getting this error when importing IonicStorageModule in my app.module:
../../node_modules/@ionic/storage-angular/fesm2020/ionic-storage-angular.mjs:2:0–51 Error: Module not found: Error: Can’t resolve ‘@angular/common’ in ‘/home/<path_to_my_project>/node_modules/@ionic/storage-angular/fesm2020’
In app.module.ts I just did:
import { IonicStorageModule } from '@ionic/storage-angular';
imports: [ ... IonicStorageModule.forRoot()]I’m using this version:
Ionic CLI : 7.2.0 (/home/baffo/.nvm/versions/node/v20.11.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.6.6
@angular-devkit/build-angular : 17.1.1
@angular-devkit/schematics : 17.1.1
@angular/cli : 17.1.1
@ionic/angular-toolkit : 9.0.0I tried this solution, but didn’t work: https://stackoverflow.com/a/64717548/10946588
Solution
Well I don’t know how exactly I fixed it but:
- I have a couple of warning complaining about ‘CommonJS or AMD dependencies’ so I added this to the
angular.json(following this solution):
"projects": {
"app": {
"build": {
"options": {
"allowedCommonJsDependencies": [
"rxjs-compat",
"localforage"
],- I revert all the changes of
package.jsonandpackage.json.lockand removednode_modulefolder. - Then, I reinstalled everything again:
npm install
npm install --save @ionic/storage
npm install --save @ionic/storage-angularAnd it’s working now.
Get Ted James’s stories in your inbox
Join Medium for free to get updates from this writer.
Answered By — Baffer
Answer Checked By — Marilyn (FixIt Volunteer)
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0





