Hello!
ionic build --prod doesn't work:
error: can't resolve module @ionic-native/core from .../node_modules/@ionic-native/status-bar/index.d.ts
[11:56:17] build dev failed: Cannot read property 'Plugin' of undefined, resolving symbol StatusBar in
/..../node_modules/@ionic-native/status-bar/index.d.ts
Is @ionic-native/core installed?
What versions are you using?
yes, it is
the dependencies from the package.json file:
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "^2.2.1",
"@ionic-native/app-rate": "^3.2.2",
"@ionic-native/camera": "^3.2.2",
"@ionic-native/core": "^3.2.4",
"@ionic-native/deeplinks": "^3.2.2",
"@ionic-native/facebook": "^3.2.2",
"@ionic-native/file": "^3.2.4",
"@ionic-native/firebase": "^3.2.2",
"@ionic-native/geolocation": "^3.2.2",
"@ionic-native/google-analytics": "^3.2.2",
"@ionic-native/image-picker": "^3.2.2",
"@ionic-native/image-resizer": "^3.2.2",
"@ionic-native/keyboard": "^3.2.2",
"@ionic-native/native-geocoder": "^3.2.2",
"@ionic-native/network": "^3.2.2",
"@ionic-native/onesignal": "^3.2.2",
"@ionic-native/sms": "^3.2.2",
"@ionic-native/social-sharing": "^3.2.2",
"@ionic-native/splash-screen": "^3.2.2",
"@ionic-native/status-bar": "^3.2.2",
"@ionic-native/transfer": "^3.2.4",
"@ionic/app-scripts": "^1.0.0",
"@ionic/storage": "^1.1.7",
"ionic-angular": "2.0.0",
"ionic-cache": "^1.1.2",
"ionic-image-loader": "^2.0.2",
"ionicons": "3.0.0",
"moment": "^2.17.1",
"ng2-translate": "^5.0.0",
"rxjs": "^5.0.0-beta.12",
"sw-toolbox": "3.4.0",
"uuid": "^3.0.1",
"zone.js": "0.6.26"
}
Try updating @ionic/app-scripts.
I can't reproduce this issue with the latest version of Ionic 2.
Can you also upgrade @ionic-native/core to 3.3.0 or downgrade to 3.2.3. Version 3.24 has a bug, not sure if it's causing this issue but it's worth a try.
ok, I upgraded some packages & ionic version, now I dodn't have that error anymore but I execute the command "ionic build android --prod" and I wait and nothing happens ( for about 10 - 15 min)
ionic build android --prod
ionic-hello-world@ ionic:build /home/victor/workspace/app
ionic-app-scripts build "--prod"
What is the last thing you see in the command prompt before it freezes?
Not sure what the problem is here, but here are a few things to try to narrow the issue down:
npm run build --prod instead of ionic buildrm -rf node_modules && npm install to re-install your node modules in case something is messed up thereno, it doesn't work, it also freezes...
I tried to build the same app but using "ionic-native" instead of "@ionic-native 3.x", and it works fine
--prod build failed after adding a plugin, no provider for Camera
@rashnk did you include Camera in providers?
This problem only occurs after installing "@ionic-native/core": "^3.4.4", which I need to for the @ionic-native/barcode-scanner...I can build without --prod fine.
I just tried ionic-native/core 3.2.3 and 3.3.0, same error.
It should also be noted that I'm using crosswalk as well.
The latest version of ionic-app-scripts is giving me issues. I could not build even without ionic-native/core. The only version that works for me for ionic-app-scripts is 1.2.2.
Here's my Ionic info:
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: OS X El Capitan
Node Version: v6.9.1
Xcode version: Xcode 8.2.1 Build version 8C1002
Here's my full log:
[15:49:57] ionic-app-scripts 1.2.2
[15:49:57] build prod started ...
[15:49:57] clean started ...
[15:49:57] clean finished in less than 1 ms
[15:49:57] copy started ...
[15:49:57] ngc started ...
can't resolve module @ionic-native/core from /Users/kamok/code/election/election-mobile/node_modules/@ionic-native/barcode-scanner/index.d.ts
[15:49:59] ionic-app-script task: "build"
[15:49:59] Error: Cannot read property 'Plugin' of undefined, resolving symbol BarcodeScanner in
/Users/kamok/code/election/election-mobile/node_modules/@ionic-native/barcode-scanner/index.d.ts
Error: Cannot read property 'Plugin' of undefined, resolving symbol BarcodeScanner in /Users/kamok/code/election/election-mobile/node_modules/@ionic-native/barcode-scanner/index.d.ts
at simplifyInContext (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler-cli/src/static_reflector.js:475:23)
at StaticReflector.simplify (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler-cli/src/static_reflector.js:478:22)
at StaticReflector.annotations (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler-cli/src/static_reflector.js:60:36)
at NgModuleResolver.resolve (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:14261:46)
at CompileMetadataResolver._loadNgModuleMetadata (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:14646:45)
at CompileMetadataResolver.getUnloadedNgModuleMetadata (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:14636:23)
at addNgModule (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:12944:43)
at /Users/kamok/code/election/election-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:12957:16
at Array.forEach (native)
at _createNgModules (/Users/kamok/code/election/election-mobile/node_modules/@angular/compiler/bundles/compiler.umd.js:12956:28)
Same problem for me ... I got this error when I tried to do "npm run build-android-release"
package.json :
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic-native/core": "^3.4.4",
"@ionic-native/google-analytics": "^3.4.4",
"@ionic/storage": "^1.1.7",
"angular2-jwt": "^0.1.27",
"auth0-js": "^8.2.0",
"intl": "^1.2.5",
"ionic-angular": "2.0.0",
"ionic-gallery-modal": "0.0.9",
"ionic-native": "^2.4.1",
"ionicons": "3.0.0",
"q": "^1.4.1",
"rxjs": "^5.3.0",
"structured-log": "^0.1.0",
"sw-toolbox": "3.4.0",
"zone.js": "0.6.26"
},
"devDependencies": {
"@ionic/app-scripts": "1.2.2",
"cordova-build-increment": "^0.1.0",
"dotenv": "^4.0.0",
"typescript": "2.0.9",
"xml2js": "^0.4.17"
}
error :
`
[10:59:52] ionic-app-scripts 1.2.2
[10:59:52] build prod started ...
[10:59:52] clean started ...
[10:59:52] clean finished in less than 1 ms
[10:59:52] copy started ...
[10:59:52] ngc started ...
can't resolve module @ionic-native/core from /Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@ionic-native/google-analytics/index.d.ts
[10:59:54] ionic-app-script task: "build"
[10:59:54] Error: Cannot read property 'Plugin' of undefined, resolving symbol GoogleAnalytics in
/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@ionic-native/google-analytics/index.d.ts
Error: Cannot read property 'Plugin' of undefined, resolving symbol GoogleAnalytics in /Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@ionic-native/google-analytics/index.d.ts
at simplifyInContext (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler-cli/src/static_reflector.js:475:23)
at StaticReflector.simplify (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler-cli/src/static_reflector.js:478:22)
at StaticReflector.annotations (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler-cli/src/static_reflector.js:60:36)
at NgModuleResolver.resolve (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler/bundles/compiler.umd.js:14261:46)
at CompileMetadataResolver._loadNgModuleMetadata (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler/bundles/compiler.umd.js:14646:45)
at CompileMetadataResolver.getUnloadedNgModuleMetadata (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler/bundles/compiler.umd.js:14636:23)
at addNgModule (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler/bundles/compiler.umd.js:12944:43)
at /Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler/bundles/compiler.umd.js:12957:16
at Array.forEach (native)
at _createNgModules (/Users/anthonyriera/Desktop/vicrltag-env/vicrltag/node_modules/@angular/compiler/bundles/compiler.umd.js:12956:28)
npm ERR! Darwin 16.4.0
npm ERR! argv "/Users/anthonyriera/.nvm/versions/node/v6.9.5/bin/node" "/Users/anthonyriera/.nvm/versions/node/v6.9.5/bin/npm" "run" "ionic:build" "--" "--prod"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! vicrltag@ ionic:build: ionic-app-scripts build "--prod"
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vicrltag@ ionic:build script 'ionic-app-scripts build "--prod"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the vicrltag package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts build "--prod"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs vicrltag
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls vicrltag
npm ERR! There is likely additional logging output above.
`
Thank you guys !
@Rieranthony I upgraded Ionic Framework version to 2.1 in my package.json and remove node_modules. Then npm cache clean followed by npm install worked for me.
@kamok Thank you for your response but that didn't work for me!
Any others solutions? :/
@Rieranthony
After i add Network,
run build --prod, Cannot read property 'Plugin' of undefined, resolving symbol Network in C:/Users//umk/node_modules/@ionic-native/network/index.d.ts**
[13:41:19] copy started ...
[13:41:19] ngc started ...
can't resolve module @ionic-native/core from C:/Users/k/node_modules/@ionic-native/network/index.d.ts
[13:41:30] build prod failed: # *# Cannot read property 'Plugin' of undefined, resolving symbol Network in C:/Users//umk/node_modules/@ionic-native/network/index.d.ts*
[13:41:30] ionic-app-script task: "build"
[13:41:30] Error: Cannot read property 'Plugin' of undefined, resolving symbol Network in C:/Users/
Ck/node_modules/@ionic-native/network/index.d.ts
Error: Cannot read property 'Plugin' of undefined, resolving symbol Network in C:/Users/Chok/node_modules/@ionic-native/network/index.d.ts
at simplifyInContext (C:\Users\Cok\node_modules\@angular\compiler-cli\src\static_reflector.js:475:23)
at StaticReflector.simplify (C:\Users\Ck\node_modules\@angular\compiler-cli\src\static_reflector.js:478:22)
at StaticReflector.annotations (C:\Users\Cok\node_modules\@angular\compiler-cli\src\static_reflector.js:60:36)
at NgModuleResolver.resolve (C:\Users\k\node_modules\@angular\compiler\bundles\compiler.umd.js:14261:46)
at CompileMetadataResolver._loadNgModuleMetadata (C:\Users\Ck\node_modules\@angular\compiler\bundles\compiler.umd.js:14646:45)
at CompileMetadataResolver.getUnloadedNgModuleMetadata (C:\Users\Ck\node_modules\@angular\compiler\bundles\compiler.umd.js:14636:23)
at addNgModule (C:\Users\Ck\node_modules\@angular\compiler\bundles\compiler.umd.js:12944:43)
at C:\Users\Ck\node_modules\@angular\compiler\bundles\compiler.umd.js:12957:16
at Array.forEach (native)
at _createNgModules (C:\Users\Cok\node_modules\@angular\compiler\bundles\compiler.umd.js:12956:28)
Just updated my package deps as per ionic 2.2.0 and I am good to go. The error is gone and build is working.
"dependencies": {
"@angular/common": "2.4.8",
"@angular/compiler": "2.4.8",
"@angular/compiler-cli": "2.4.8",
"@angular/core": "2.4.8",
"@angular/forms": "2.4.8",
"@angular/http": "2.4.8",
"@angular/platform-browser": "2.4.8",
"@angular/platform-browser-dynamic": "2.4.8",
"@angular/platform-server": "2.4.8",
"@ionic-native/core": "3.4.4",
"@ionic-native/geolocation": "^3.4.4",
"@ionic/storage": "2.0.1",
"@types/lodash": "ts2.0",
"annyang": "2.6.0",
"ionic-angular": "2.3.0",
"ionic-native": "2.9.0",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26"
}
@shivamsngh thanks, it worked for me too !
Most helpful comment
@rashnk did you include Camera in providers?