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

Getting this error when I try ionic serve

The error is about missing some js files…I am using type script and I can see the ts file…

The errors details

> ionic-app-base@ ionic:serve C:\Projects\kidsTokens
> ionic-app-scripts serve "--v2" "--address" "0.0.0.0" "--port" "8100" "--livereload-port" "35729"

keywords if/then/else require v5 option
[22:04:05]  ionic-app-scripts 0.0.48
[22:04:05]  watch started ...
[22:04:05]  build dev started ...
[22:04:05]  clean started ...
[22:04:05]  clean finished in 9 ms
[22:04:05]  copy started ...
[22:04:05]  transpile started ...
[22:04:09]  transpile finished in 3.46 s
[22:04:09]  webpack started ...
[22:04:09]  copy finished in 3.59 s
(node:7612) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file
 or directory, open 'C:\Projects\kidsTokens\src\pages\task\taskInfo.js'
(node:7612) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are
not handled will terminate the Node.js process with a non-zero exit code.
(node:7612) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: ENOENT: no such file
 or directory, open 'C:\Projects\kidsTokens\src\pages\task\taskInfo.js.map'
(node:7612) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: ENOENT: no such file
 or directory, open 'C:\Projects\kidsTokens\src\pages\child\childInfo.js'
(node:7612) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: ENOENT: no such file
 or directory, open 'C:\Projects\kidsTokens\src\pages\child\childInfo.js.map'
[22:04:17]  webpack finished in 7.95 s
[22:04:17]  sass started ...
[22:04:18]  sass finished in 1.15 s
[22:04:18]  build dev finished in 12.59 s
[22:04:18]  watch ready in 12.67 s
[22:04:18]  dev server running: http://localhost:8100/

System information

Your system information:

 ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 0.0.48
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v7.3.0
Xcode version: Not installed

Any advice please

Does the problem persist with LTS node version?

yes…still getting the error after upgrading node

any update with the same issue ???

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

Hi ,

just a confirmation, i have the same issue but only during --prod build,
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ENOENT: no such file
or directory …

The import statement:
import { DashboardPage } from ‘…/pages/Dashboard/Dashboard’;

the correct one:
import { DashboardPage } from ‘…/pages/dashboard/dashboard’;

notice the lowercase/uppercase filenames!!!

so during the build phase, the internal file names are case sensitives.

Regards

7 Likes

Thanks a ton!!! In my case the folder name was in caps and the import statement didnt have caps.

2 Likes

You’re right. Thanks !! PD: I use Windows.

Hi All,

I am using Ionic, and get the following error:

Runtime Error Uncaught (in promise): Error: Module build failed:
Error: ENOENT: no such file or directory, open
‘/Users/richardmarais/Development/ionic/theWhoZoo/src/pages/model/ratingModel.js’

The error is a result of this line of code:

this.ratingModel = new RatingModel();

When I remove this line, I don’t get the error.

ratingModel.ts

import { Injectable } from "@angular/core";
import { PersonModel } from './personModel';
import { JobModel } from './jobModel';

@Injectable()
export class RatingModel {
        public id: number = null;
        public job: JobModel = null;
        public review: string = null;
        public rating: number = null;
        public reviewDate: number = null;
        public time: string = null;
        public person: PersonModel = null;
        public anonymous: number = null;
        
        constructor() {
                
        }
}

Reading other forums, people are getting this error due to the case not matching in their imports, but I have checked mine, and they do match.

import { RatingModel } from '../model/ratingModel';

However, I have noticed something strange in my IDE (Visual Studio Code):

enter image description here

As you can see, in the search results, there are two files for the object, ratingModel.ts and RatingModel.ts. But when I check the actual files system, there is only on file, ratingModel.ts:

enter image description here

Question

Does anyone know what and how to resolve what looks like possibly a bug or fault here?

Thanks

More info:

global packages:

    @ionic/cli-utils : 1.0.0
    Cordova CLI      : 6.4.0 
    Ionic CLI        : 3.0.0

local packages:

    @ionic/app-scripts              : 1.3.0
    @ionic/cli-plugin-cordova       : 1.0.0
    @ionic/cli-plugin-ionic-angular : 1.0.0
    Ionic Framework                 : ionic-angular 3.2.1

System:

    Node       : v7.10.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002 
    ios-deploy : not installed
    ios-sim    : not installed
1 Like

I think you have a case mismatch in an import somewhere.

I have read that other users had this issue due to a case miss-match, so I have checked my imports, and they are correct.

One thing I have just tried, which worked, but it still does not explain the error, is I changed the file and imports from ratingModel.ts to RatingModel.ts.

1 Like

You shouldn’t ever be importing things with explicit suffixes like .ts, but glad it’s working.

I don’t, I changed:

import { RatingModel } from '../model/ratingModel';

to:

import { RatingModel } from '../model/RatingModel';

1 Like

But it does appear as if there’s is a bug in Ionic or one of its supporting libs.

Apologies, my bad. I just found another file that was importing the object with the incorrect case. It does appear as if there is no issue, and I had a bug in my code.

import { RatingModel } from '../model/RatingModel';

men you saved my day :slight_smile:

1 Like

Thanks a lot…solved my problem

If any of solutions above doesnt work. try to re-serve (ionic serve). worked for me

Thanks , you’re right !! XD

For God. Thankssssssssssssss a lot !!!
the path must be lowercase !!!