Error: Cannot find module 'internal/fs'

I wrote an Ionic v1 app two years ago targeting iOS and Android. I need to rebuild the app so it is compatible with iOS 11. I also need to troubleshoot why local notifications no longer work. I installed the latest versions of Ionic CLI (3.7.0), Cordova (7.0.1), Node (8.2.1), and NPM (5.3.0) but am having a difficult time getting my old app to build.

At this point I’m trying to build a brand new Ionic v1 app with the hope that I can copy over relevant code from my old project. I’m trying to add ngCordova to the new app and get Error: Cannot find module 'internal/fs'. Any thoughts on how to fix?

STR:

ionic start ExampleApp blank --type ionic1 --n "ExampleApp" --cordova
cd ExampleApp
ionic cordova platform add ios
ionic cordova platform add android
bower install ngCordova

Error:

Error: Cannot find module ‘internal/fs’
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at evalmachine.:40:20
at Object. (/usr/local/lib/node_modules/bower/node_modules/graceful-fs/fs.js:11:1)
at Module._compile (module.js:569:30)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)

Info:

cli packages: ([...excludedByMe]/node_modules)

    @ionic/cli-plugin-cordova : 1.6.2
    @ionic/cli-plugin-gulp    : 1.1.1
    @ionic/cli-plugin-ionic1  : 2.1.1
    @ionic/cli-utils          : 1.7.0
    ionic (Ionic CLI)         : 3.7.0

global packages:

    Cordova CLI : 7.0.1 
    Gulp CLI    : CLI version 3.9.0 Local version 3.9.1

local packages:

    Cordova Platforms : android 6.2.3 ios 4.4.0
    Ionic Framework   : ionic1 1.3.3

System:

    Node       : v8.2.1
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    ios-sim    : 4.1.1 
    npm        : 5.3.0

I had the same issue. I fixed it by downgrading node for my v1 project. I use 8.x for v2 and I think 5.x or 6.x for v1. I use ‘n’ so switching is easy. What I don’t remember is if there was some npm version dep too

For the record, Ionic1 expects Node 6 LTS.

Info:

cli packages: ([...excludedByMe]/node_modules)

    @ionic/cli-plugin-cordova : 1.6.2
    @ionic/cli-plugin-gulp    : 1.1.1
    @ionic/cli-plugin-ionic1  : 2.1.1
    @ionic/cli-utils          : 1.7.0
    ionic (Ionic CLI)         : 3.7.0

global packages:

    Cordova CLI : 7.0.1 
    Gulp CLI    : CLI version 3.9.0 Local version 3.9.1

local packages:

    Cordova Platforms : android 6.2.3 ios 4.4.0
    Ionic Framework   : unknown

System:

    Node       : v6.11.2
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    ios-sim    : 4.1.1 
    npm        : 3.10.10

Tips for upgrading an old Ionic v1 project that you haven’t touched in years:

  • Update Ionic CLI
  • Update Cordova
  • Install nvm so you can switch between Node versions easily
  • Install Node 6 LTS
  • Create a brand new Ionic v1 app so you understand what a project should look like.
    • Root package.json and config.xml may have a different structures.
    • gulpfile.js may have changed
    • You may have to create new icons for additional iOS icons
  • Reinstall bower packages (i.e. stuff in /www/lib/)
  • Reinstall node packages
  • Remove all plugins and re-add: ionic cordova plugin rm/add ...
  • Installing ngCordova seems to delete a few files that the Ionic CLI seems to care about, namely www/lib/ionic/version.json. This throws an error when running ionic info but doesn’t seem to matter otherwise.
  • Revist your Content Security Policy if the splash screen doesn’t disappear