Open shyamal890 opened 7 years ago
I got the same error when i tried to build my app in prod release mode ;
ionic-app-script task: "build" [14:45:14] Error: ./src/providers/Appload.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader
Anyone can help??
I've got the same error :
ionic-app-script task: "build"
[11:07:24] Error: ./api/server/collections/index.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader
I have downgrade the package @ionic/app-scripts to the version 1.3.4 and now everything is ok.
This error generally happens when filename don't match at the given path. Git is insensitive to the filename. Appload.ts if is "appload.ts" then this will fail. Ensure on file where it is failing the file name is correct.
The point where this error occurs is due to file not found at that path.
I'm getting this error message because I'm referencing a .ts file in my node api folder. I'm wondering whether it's erroring because it's not in the src folder.
@RobertYoung : could you share some code or repo to reproduce?
@jayeshanandani Here is an example repo. Run the build:prod script.
https://github.com/RobertYoung/ionic-build-prod-error-sample
I'm also getting build --prod issues for android, without --prod works fine though
Happening to me, too on ngx-uploader module. https://github.com/jkuri/ngx-uploader
[14:13:25] ionic-app-script task: "build"
[14:13:25] Error: ./~/ngx-uploader/src/ngx-uploader/module/ngx-uploader.module.ts Module build failed: TypeError:
Cannot read property 'content' of undefined at Object.optimizationLoader
(/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader
(/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/app/app.module.ngfactory.js 29:0-85 @
./src/app/main.ts,./~/ngx-uploader/src/ngx-uploader/directives/ng-file-drop.directive.ts Module build
failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader
(/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader
(/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/pages/manage-event-pairings/manage-event-pairings.ngfactory.js 31:0-92 @
./src/pages/manage-event-pairings/manage-event-pairings.module.ngfactory.ts @ ./src lazy @
./~/ionic-angular/util/ng-module-loader.js @ ./src/app/app.module.ngfactory.js @
./src/app/main.ts,./~/ngx-uploader/src/ngx-uploader/directives/ng-file-select.directive.ts Module build
failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader
(/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader
(/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/pages/manage-event-pairings/manage-event-pairings.ngfactory.js 40:0-94 @
./src/pages/manage-event-pairings/manage-event-pairings.module.ngfactory.ts @ ./src lazy @
./~/ionic-angular/util/ng-module-loader.js @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts
Error: ./~/ngx-uploader/src/ngx-uploader/module/ngx-uploader.module.ts
Module build failed: TypeError: Cannot read property 'content' of undefined
at Object.optimizationLoader (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/app/app.module.ngfactory.js 29:0-85
@ ./src/app/main.ts,./~/ngx-uploader/src/ngx-uploader/directives/ng-file-drop.directive.ts
Module build failed: TypeError: Cannot read property 'content' of undefined
at Object.optimizationLoader (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/pages/manage-event-pairings/manage-event-pairings.ngfactory.js 31:0-92
@ ./src/pages/manage-event-pairings/manage-event-pairings.module.ngfactory.ts
@ ./src lazy
@ ./~/ionic-angular/util/ng-module-loader.js
@ ./src/app/app.module.ngfactory.js
@ ./src/app/main.ts,./~/ngx-uploader/src/ngx-uploader/directives/ng-file-select.directive.ts
Module build failed: TypeError: Cannot read property 'content' of undefined
at Object.optimizationLoader (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/pages/manage-event-pairings/manage-event-pairings.ngfactory.js 40:0-94
@ ./src/pages/manage-event-pairings/manage-event-pairings.module.ngfactory.ts
@ ./src lazy
@ ./~/ionic-angular/util/ng-module-loader.js
@ ./src/app/app.module.ngfactory.js
@ ./src/app/main.ts
at BuildError.Error (native)
at new BuildError (/Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /Users/lb3/projects/maritlabs/marit-mtg-ionic-web/node_modules/@ionic/app-scripts/dist/preprocess.js:18:21
at process._tickCallback (internal/process/next_tick.js:103:7)
Cordova CLI: 6.4.0
Ionic Framework Version: 3.4.2
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.12
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v6.8.1
Xcode version: Xcode 8.3.3 Build version 8E3004b
I'm also getting the same issue:
[12:19:12] ionic-app-script task: "build"
[12:19:12] Error: ./environment/environment-variables.module.ts Module build failed: TypeError: Cannot read property
'content' of undefined at Object.optimizationLoader
(/home/philliphartin/Development/project_x/ionic/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader
(/home/philliphartin/Development/project_x/ionic/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/app/app.module.ngfactory.js 19:0-74 @ ./src/app/main.ts,./environment/environment-variables.token.ts
Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader
(/home/philliphartin/Development/project_x/ionic/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader
(/home/philliphartin/Development/project_x/ionic/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/app/app.module.ngfactory.js 109:0-74 @ ./src/app/main.ts
Error: ./environment/environment-variables.module.ts
Module build failed: TypeError: Cannot read property 'content' of undefined
at Object.optimizationLoader (/home/philliphartin/Development/project_x/ionic/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader-impl.js:14:24)
at Object.loader (/home/philliphartin/Development/project_x/ionic/node_modules/@ionic/app-scripts/dist/webpack/optimization-loader.js:5:32)
@ ./src/app/app.module.ngfactory.js 19:0-74
Environment:
global packages:
@ionic/cli-utils : 1.5.0
Cordova CLI : 7.0.1
Gulp CLI : CLI version 1.3.0 Local version 3.9.1
Ionic CLI : 3.5.0
local packages:
@ionic/app-scripts : 2.0.2
@ionic/cli-plugin-cordova : 1.4.1
@ionic/cli-plugin-gulp : 1.0.2
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms : browser 4.1.0
Ionic Framework : ionic-angular 3.5.3
System:
Node : v6.11.0
OS : Linux 4.10
Xcode : not installed
ios-deploy : not installed
ios-sim : not installed
npm : 3.10.10
UPDATE: My issue was that I was referencing a file not under the src directory. When I moved the containing folder to src. This fixed the issue for me
I have the same problem
$ ionic info 1 ↵ 8.1.4 ⬢
cli packages:
@ionic/cli-plugin-cordova : 1.5.0
@ionic/cli-plugin-ionic-angular : 1.4.0
@ionic/cli-utils : 1.6.0
ionic (Ionic CLI) : 3.6.0
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.1.3
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.6.0
System:
Android SDK Tools : 26.0.2
Node : v8.1.4
OS : macOS Sierra
npm : 5.0.3
and using angular 4.1.3
Any update on this?
Thanks
same here with clean ionic-app-scripts project using default webpack.config. I added a typescript module using npm link.
same error using app-scripts 1.3.7 and --prod
In my case, I was importing files from outside /src directory. The Webpack is trying to get the compiled js file from the original typescript folder. I've disabled the optimizer and the real error shows up.
PS C:\temp\myapp> $env:IONIC_MANUAL_TREESHAKING= 'false'
PS C:\temp\myapp> $env:IONIC_PURGE_DECORATORS='false'
#build
PS C:\temp\myapp> ionic cordova run android --prod
Running app-scripts build: --prod --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --nobrowser
[14:08:38] build prod started ...
[14:08:38] clean started ...
[14:08:38] clean finished in 10 ms
[14:08:38] copy started ...
[14:08:38] ngc started ...
[14:08:46] ngc finished in 7.98 s
[14:08:46] preprocess started ...
[14:08:46] deeplinks started ...
[14:08:46] deeplinks finished in 106 ms
[14:08:46] optimization started ...
[14:08:46] optimization finished in 12 ms
[14:08:46] preprocess finished in 122 ms
[14:08:46] webpack started ...
[14:08:47] copy finished in 8.45 s
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova).
Error: ./server/test.model.ts
Module build failed: Error: ENOENT: no such file or directory, open 'C:\temp\myapp\server\test.model.js'
at Error (native)
@ ./src/pages/home/home.ts 12:0-52
@ ./src/app/app.module.ts
@ ./src/app/app.module.ngfactory.ts
@ ./src/app/main.ts
I solved the problem including the server folder into tsconfig file.
"include": [
"src/**/*.ts",
"server/**/*.model.ts",
];
Thanks.
thanks @allanclempe, I had the same issue
A mi me paso simplemente por un problema de mayusculas y minusculas! Me tire horas buscando...
I believe a webpack plugin decided to no longer accepts my declaration files that had the extension .d.ts
. I had a file with only type annotations named user.d.ts
and I was forced to rename it to user.ts
. This allowed me to get passed the error.
I had the same error where Module build failed: TypeError: Cannot read property 'content' of undefined
.
I didn't change any of my code, this only happened after I updated @ionic/app-scripts@2.1.4
. I also tried @ionic/app-scripts@2.0.2
and got the same error.
While ionic-app-scripts serve
worked flawlessly, ionic-app-scripts build --prod --release
stopped working.
"Properly" downgrading or updating to different versions Angular, Ionic-Angular,and @angular/cli didn't fix the error. I was using the current versions.
@ionic/cli-utils : 1.12.0
ionic (Ionic CLI) : 3.12.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 2.1.4
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.6.1
System:
Android SDK Tools : 25.2.3
Node : v7.4.0
npm : 4.0.5
OS : Windows 10
I had the same issue and it turned out to be a case issue in the app.module. A file within a folder was referenced as userLogin and not userlogin. Fixing this resolved my issue.
Hi,
I had same issues. My typescript files were in a folder called Models. I rename it models (lowercase) and problem is solved.
As previously said, it looks like a "case problem" ... I was dealing with the same issue. Just check if one of your file or folder name doesn't contain Uppercase in it's context
For me it was in "pages" -templateView (instead of "templateview) -templateview.ts -templateview.html -templateview.scss
Really couldn't make any head way in terms of debugging this issue. Would really appreciate some help here.
Ionic Info: