Runtime Error Module build failed: Error: ENOENT: no such file or directory,

I’m having the same issue after updating all my npm packages.

It’s trying to find a .js-file and a .js.map file

Here’s the exact error:

(node:4919) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file or directory, open '/Users/timmyrosen/Sites/Rekon/src/services/user.js'
(node:4919) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: ENOENT: no such file or directory, open '/Users/timmyrosen/Sites/Rekon/src/services/user.js.map'

Just to be clear, these files do not exist and I do not reference them anywhere. I use Typescript

Here’s my package.json:

"scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.4.1",
    "@angular/compiler": "2.4.1",
    "@angular/compiler-cli": "2.4.1",
    "@angular/core": "2.4.1",
    "@angular/forms": "2.4.1",
    "@angular/http": "2.4.1",
    "@angular/platform-browser": "2.4.1",
    "@angular/platform-browser-dynamic": "2.4.1",
    "@angular/platform-server": "2.4.1",
    "@ionic/storage": "1.1.7",
    "angular2-moment": "^1.0.0",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.2.13",
    "ionicons": "3.0.0",
    "moment": "^2.17.1",
    "ng2-cache": "^0.1.5",
    "rxjs": "5.0.2",
    "zone.js": "0.7.4"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.48",
    "typescript": "2.1.4"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-statusbar",
    "cordova-plugin-console",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [
    "ios",
    {
      "platform": "ios",
      "version": "",
      "locator": "ios"
    }
  ],

And here is my ionic info:

Cordova CLI: 6.4.0 
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.48
ios-deploy version: 1.8.6 
ios-sim version: 5.0.8 
OS: macOS Sierra
Node Version: v6.9.1
Xcode version: Xcode 8.2.1 Build version 8C1002

UPDATE:
Also tried with the latest Node version (7.3.0) and I have the same issue

UPDATE:
I found the exact line in the build/main.js that causes the error:

//# sourceMappingURL=User.js.map

/***/ },
/* 777 */
/***/ function(module, exports) {

throw new Error("Module build failed: Error: ENOENT: no such file or directory, open '/Users/timmyrosen/Sites/Rekon/src/services/user.js'");

/***/ },
/* 778 */
/***/ function(module, exports, __webpack_require__) {

"use strict";

I’ve tried deleting all build files but the problem reappears every time.

UPDATE:

Ok, i’ve managed to get it working if I remove my User service from my providers array in app.module.ts.

Even if I remove almost everything in my User service, the problem still persists.

UPDATE:

Ok, I found the problem.

Here is my previous import line that caused the issue:
import { User } from '../../services/User';

Here is the corrected line that solved the issue:
import { User } from '../../services/user';

After having wasted almost an entire workday on this, I feel that the error messages could have some work done on.

13 Likes