Cannot read property 'hasOwnProperty' of undefined


#1

Hi,

Start give this exception after I upgraded my ionic version to 2.1.4

There was an error serving your Ionic application: TypeError: Cannot read property ‘hasOwnProperty’ of undefined
at C:\Users\Sezer\AppData\Roaming\npm\node_modules\ionic\lib\utils\npmScripts.js:16:31
at _fulfilled (C:\Users\Sezer\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\Sezer\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\Sezer\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:749:13)
at C:\Users\Sezer\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:557:44
at flush (C:\Users\Sezer\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:108:17)
at nextTickCallbackWith0Args (node.js:452:9)
at process._tickCallback (node.js:381:13)


#2

I’ve a very similar problem…

TypeError: Cannot read property ‘hasOwnProperty’ of undefined
at Object.runr (C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\lib\cli.js:191:19)
at C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\lib\cli.js:54:9
at _fulfilled (C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:749:13)
at C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:557:44
at flush (C:\Users\JWOJCIK\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:108:17)
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)

Cannot read property ‘hasOwnProperty’ of undefined (CLI v2.1.7)


#3

ionic platform add android

TypeError: Cannot read property ‘hasOwnProperty’ of undefined
at Object.runr (C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\lib\cli.js:191:19)
at C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\lib\cli.js:54:9
at _fulfilled (C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:749:13)
at C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:557:44
at flush (C:\Users\Kevin\AppData\Roaming\npm\node_modules\ionic\node_modules\q\q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)

Cannot read property ‘hasOwnProperty’ of undefined (CLI v2.1.7)

Your system information:

ordova CLI: 6.4.0
Ionic CLI Version: 2.1.7
Ionic App Lib Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.1
Xcode version: Not installed

Same error here guys, already opened an issue on github :confounded:


#4

Please post the “scripts” stanza of your package.json. If the answer is “there isn’t one”, that’s your problem. Make it look like the one in a freshly generated project.


#5

Same problem, this is my package.json, i’m creating a new project using the command ionic start myApp tabs

—package.json
{
“name”: “blank”,
“version”: “1.1.1”,
“description”: “blank: An Ionic project”,
“dependencies”: {
“gulp”: “^3.5.6”,
“gulp-sass”: “^2.0.4”,
“gulp-concat”: “^2.2.0”,
“gulp-minify-css”: “^0.3.0”,
“gulp-rename”: “^1.2.0”
},
“devDependencies”: {
“bower”: “^1.3.3”,
“gulp-util”: “^2.2.14”,
“shelljs”: “^0.3.0”
},
“cordovaPlugins”: [
“cordova-plugin-whitelist”,
“cordova-plugin-console”,
“cordova-plugin-statusbar”,
“cordova-plugin-device”,
“cordova-plugin-splashscreen”,
“ionic-plugin-keyboard”
],
“cordovaPlatforms”: []
}

—ERROR DETAIL
Cannot read property ‘hasOwnProperty’ of undefined (CLI v2.1.7)

Your system information:

Cordova CLI: 6.4.0
Ionic CLI Version: 2.1.7
Ionic App Lib Version: 2.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v4.5.0
Xcode version: Not installed


#6

Ok, I downgrade ionic cli (1.7.6) and cordova (5.4) and all work fine…

I’m sorry for reply about ionic 1 in this ionic 2 post.


#7

Cordova CLI: 6.2.0
Ionic CLI Version: 2.1.14
Ionic App Lib Version: 2.1.7
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v6.9.2
Xcode version: Not installed

ionic run android TypeError: Cannot read property ‘hasOwnProperty’ of undefined
at /usr/lib/node_modules/ionic/lib/utils/npmScripts.js:17:31
at _fulfilled (/usr/lib/node_modules/ionic/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/lib/node_modules/ionic/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/lib/node_modules/ionic/node_modules/q/q.js:749:13)
at /usr/lib/node_modules/ionic/node_modules/q/q.js:557:44
at flush (/usr/lib/node_modules/ionic/node_modules/q/q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Faulty line is return packageJsonContents.hasOwnProperty('scripts') so something about a json config file.
I just created a package.json with empty json {} in the root of the project and it fixed the problem.
Seems like ionic cli 2.x uses now ionic.config.json but npm still needs package.json


#9

Thanks this worked perfectly.