Search code examples
node.jsangularnpmionic-framework

An unhandled exception occurred: Cannot find module 'node:fs'


When i run Ionic generate page, i got this error:

An unhandled exception occurred: Cannot find module 'node:fs'

It Happened after i change my node js version to 14.15.0. i forgot what version of node js that i used before. and i cant find any solution anywhere about this problem. i've been trying to change node version to other version but it just gave me new different kind of error.

Here is my package.json looks like

 {
  "name": "sbh_mobile",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~12.0.1",
    "@angular/core": "~12.0.1",
    "@angular/forms": "~12.0.1",
    "@angular/platform-browser": "~12.0.1",
    "@angular/platform-browser-dynamic": "~12.0.1",
    "@angular/router": "~12.0.1",
    "@auth0/angular-jwt": "^5.0.2",
    "@awesome-cordova-plugins/core": "^5.41.0",
    "@awesome-cordova-plugins/device": "^5.45.0",
    "@awesome-cordova-plugins/geolocation": "^5.45.0",
    "@awesome-cordova-plugins/in-app-browser": "^5.46.0",
    "@awesome-cordova-plugins/ionic-webview": "^6.2.0",
    "@awesome-cordova-plugins/native-geocoder": "^5.45.0",
    "@awesome-cordova-plugins/onesignal": "^5.44.0",
    "@awesome-cordova-plugins/screen-orientation": "^6.2.0",
    "@capacitor-community/background-geolocation": "git+https://github.com/pdrhlik/background-geolocation.git",
    "@capacitor-community/camera-preview": "^3.1.2",
    "@capacitor/android": "3.3.1",
    "@capacitor/app": "1.0.2",
    "@capacitor/camera": "^1.2.4",
    "@capacitor/core": "^3.3.1",
    "@capacitor/haptics": "1.0.2",
    "@capacitor/keyboard": "^1.0.1",
    "@capacitor/local-notifications": "^1.1.0",
    "@capacitor/network": "^1.0.7",
    "@capacitor/splash-screen": "^1.2.2",
    "@capacitor/status-bar": "^1.0.2",
    "@capacitor/storage": "^1.2.3",
    "@capgo/native-market": "^1.1.11",
    "@coreui/angular": "^4.2.14",
    "@coreui/coreui": "^4.2.2",
    "@ionic-native/aes-256": "^5.36.0",
    "@ionic-native/android-permissions": "^5.36.0",
    "@ionic-native/app-version": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/fingerprint-aio": "^5.36.0",
    "@ionic-native/google-plus": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/native-storage": "^5.36.0",
    "@ionic-native/themeable-browser": "^4.20.0",
    "@ionic-native/uid": "^5.36.0",
    "@ionic-native/unique-device-id": "^5.36.0",
    "@ionic/angular": "^6.3.7",
    "@ionic/core": "^6.0.2",
    "@ionic/pwa-elements": "^3.1.1",
    "@ionic/storage": "^3.0.6",
    "@ionic/vue": "^6.0.1",
    "@ionic/vue-router": "^6.0.1",
    "bootstrap": "^5.2.2",
    "cordova-plugin-aes256-encryption": "^2.0.1",
    "cordova-plugin-android-permissions": "^1.1.2",
    "cordova-plugin-app-version": "^0.1.14",
    "cordova-plugin-device": "^2.1.0",
    "cordova-plugin-fingerprint-aio": "^5.0.1",
    "cordova-plugin-geolocation": "^4.1.0",
    "cordova-plugin-googleplus": "^8.5.2",
    "cordova-plugin-inappbrowser": "^5.0.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-nativegeocoder": "^3.4.1",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-uid": "^1.3.0",
    "cordova-sqlite-storage": "^6.0.0",
    "crypto-js": "^4.1.1",
    "es6-promise-plugin": "^4.2.2",
    "google-libphonenumber": "^3.2.27",
    "ionic-keyboard-assist": "^4.0.2",
    "jsqr": "^1.4.0",
    "lottie-web": "^5.10.1",
    "ngx-lottie": "^7.0.4",
    "ngx-pagination": "^6.0.2",
    "ngx-pipes": "^2.7.6",
    "onesignal-cordova-plugin": "^3.1.1",
    "rxjs": "~6.6.0",
    "swiper": "^8.4.4",
    "tslib": "^2.0.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.0.1",
    "@angular-eslint/builder": "~12.0.0",
    "@angular-eslint/eslint-plugin": "~12.0.0",
    "@angular-eslint/eslint-plugin-template": "~12.0.0",
    "@angular-eslint/template-parser": "~12.0.0",
    "@angular/cli": "~12.0.1",
    "@angular/compiler": "~12.0.1",
    "@angular/compiler-cli": "~12.0.1",
    "@angular/language-service": "~12.0.1",
    "@capacitor/cli": "^3.9.0",
    "@ionic/angular-toolkit": "^8.0.0",
    "@ionic/lab": "3.2.10",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@typescript-eslint/eslint-plugin": "4.16.1",
    "@typescript-eslint/parser": "4.16.1",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.7.1",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "typescript": "~4.2.4"
  },
  "description": "An Ionic project"
}

Please, help me to solve this problem... thank you


Solution

  • Thanks for all the help. Fortunately I have the older folder of my project. and I match all the devDependencies version. I found out that version of my @ionic/angular-toolkit in my older folder is ^4.0.0 and the new one is ^6.0.0. I don't know how it change. but I already downgrade it to 4.0.0 and the ionic g page is now working fine.....