ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 302 forks source link

Cannot read property '0' of undefined - on 3.6.0 #1152

Open gigocabrera opened 7 years ago

gigocabrera commented 7 years ago

Short description of the problem:

I tried to follow the steps for ionic release 3.6.0 and when I try to install app-scripts I get the error shown below

https://github.com/ionic-team/ionic/releases

gigocabrera@Macintosh:~/Documents/ionic/CajaFuerte-app$ npm install @ionic/app-scripts@latest --save-dev
npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
npm WARN ionic-img-viewer@2.4.0 requires a peer of ionic-angular@~3.4.0 but none was installed.
npm WARN ng2-translate@5.0.0 requires a peer of @angular/core@^2.0.0 but none was installed.
npm WARN ng2-translate@5.0.0 requires a peer of @angular/http@^2.0.0 but none was installed.
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.

npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/gigocabrera/.npm/_logs/2017-07-27T22_35_17_545Z-debug.log

What behavior are you expecting?

I was expecting the upgrade to work without any issues

Steps to reproduce:

  1. npm install -g ionic@latest
  2. npm install @ionic/app-scripts@latest --save-dev
  3. npm install ionic-angular@latest --save

Which @ionic/app-scripts version are you using?

Other information:

ionic info is not working anymore but here's a copy of my package.json

{
  "name": "CajaFuerte",
  "author": "Luis Cabrera",
  "homepage": "http://luiscabrera.site/",
  "private": true,
  "version": "2.1.0",
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/app-rate": "^4.1.0",
    "@ionic-native/app-version": "^4.1.0",
    "@ionic-native/camera": "4.1.0",
    "@ionic-native/core": "4.1.0",
    "@ionic-native/email-composer": "^4.1.0",
    "@ionic-native/in-app-browser": "^4.1.0",
    "@ionic-native/keyboard": "^4.1.0",
    "@ionic-native/native-audio": "^4.1.0",
    "@ionic-native/splash-screen": "4.1.0",
    "@ionic-native/status-bar": "4.1.0",
    "@ionic-native/touch-id": "4.1.0",
    "@ionic/app-scripts": "2.0.2",
    "@ionic/cloud-angular": "^0.12.0",
    "@ionic/storage": "2.0.1",
    "angularfire2": "^4.0.0-rc.1",
    "cordova-ios": "~4.3.1",
    "cordova-plugin-app-version": "~0.1.9",
    "cordova-plugin-apprate": "^1.3.0",
    "cordova-plugin-camera": "~2.4.1",
    "cordova-plugin-console": "1.0.5",
    "cordova-plugin-device": "1.1.4",
    "cordova-plugin-dialogs": "^1.3.3",
    "cordova-plugin-email": "^1.2.6",
    "cordova-plugin-globalization": "^1.0.7",
    "cordova-plugin-inappbrowser": "~1.6.1",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-splashscreen": "~4.0.1",
    "cordova-plugin-statusbar": "2.2.1",
    "cordova-plugin-whitelist": "1.3.1",
    "firebase": "4.1.5",
    "font-awesome": "4.7.0",
    "gsap": "1.19.1",
    "ionic-angular": "3.5.3",
    "ionic-img-viewer": "^2.4.0",
    "ionic-plugin-deploy": "~0.6.7",
    "ionic-plugin-keyboard": "~2.2.1",
    "ionicons": "3.0.0",
    "moment": "2.18.1",
    "ng2-translate": "^5.0.0",
    "promise-polyfill": "6.0.2",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.0.2",
    "@ionic/cli-plugin-cordova": "1.4.1",
    "@ionic/cli-plugin-ionic-angular": "1.3.2",
    "typescript": "2.3.4"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "Password Manager App Developed with Ionic and Firebase",
  "config": {
    "ionic_copy": "./scripts/copy-custom-libs.js"
  },
  "cordova": {
    "platforms": [
      "ios"
    ],
    "plugins": {
      "cordova-plugin-camera": {
        "CAMERA_USAGE_DESCRIPTION": "Cajafuerte needs access to your camera",
        "PHOTOLIBRARY_USAGE_DESCRIPTION": "CajaFuerte needs access to your photo library"
      },
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-deploy": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-email": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-nativeaudio": {},
      "cordova-plugin-apprate": {}
    }
  }
}
gigocabrera commented 7 years ago

UPDATE

NPM version 5.3.0 node 7.10.0

I tried using sudo to no avail I tried deleting node_modules to no avail

This is what I see from the npm error log file

7510 silly extract caseless@https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz
7511 silly extract base64-js@https://registry.npmjs.org/base64-js/-/base64-js-1.1.2.tgz
7512 silly extract q@https://registry.npmjs.org/q/-/q-1.5.0.tgz
7513 silly extract shelljs@https://registry.npmjs.org/shelljs/-/shelljs-0.3.0.tgz
7514 silly extract q@https://registry.npmjs.org/q/-/q-1.5.0.tgz
7515 silly extract cordova-app-hello-world@https://registry.npmjs.org/cordova-app-hello-world/-/cordova-app-hello-world-3.12.0.tgz
7516 silly extract cookie-signature@https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz
7517 silly extract cookie@https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz
7518 silly doReverseSerial unbuild 4242
7519 silly unbuild @ionic/app-scripts@2.1.3
7520 info lifecycle @ionic/app-scripts@2.1.3~preuninstall: @ionic/app-scripts@2.1.3
7521 info lifecycle @ionic/app-scripts@2.1.3~uninstall: @ionic/app-scripts@2.1.3
7522 verbose unbuild rmStuff @ionic/app-scripts@2.1.3 from /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules
7523 silly isEverInside /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/.bin/ionic-app-scripts is not inside /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/@ionic/app-scripts
7524 silly gentlyRm parent.path = /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/@ionic/app-scripts
7525 silly gentlyRm parent.managed = /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/@ionic/app-scripts is in /Users/gigocabrera/Documents/ionic/CajaFuerte-app
7526 silly gentlyRm target.path =  /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/.bin/ionic-app-scripts
7527 silly gentlyRm target.symlink = ../@ionic/app-scripts/bin/ionic-app-scripts.js
7528 silly gentlyRm target.managed = /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/.bin/ionic-app-scripts is in /Users/gigocabrera/Documents/ionic/CajaFuerte-app
7529 silly gentlyRm target.inParent =  { target: '/Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js',
7529 silly gentlyRm   path: '/Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/@ionic/app-scripts' }
7530 info lifecycle @ionic/app-scripts@2.1.3~postuninstall: @ionic/app-scripts@2.1.3
7531 silly unbuild cordova
7532 info lifecycle undefined~preuninstall: undefined
7533 info lifecycle undefined~uninstall: undefined
7534 verbose unlock done using /Users/gigocabrera/.npm/_locks/staging-ee0997c7537d05fd.lock for /Users/gigocabrera/Documents/ionic/CajaFuerte-app/node_modules/.staging
7535 warn ionic-img-viewer@2.4.0 requires a peer of ionic-angular@~3.4.0 but none was installed.
7536 warn ng2-translate@5.0.0 requires a peer of @angular/core@^2.0.0 but none was installed.
7537 warn ng2-translate@5.0.0 requires a peer of @angular/http@^2.0.0 but none was installed.
7538 warn ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
7539 verbose stack TypeError: Cannot read property '0' of undefined
7539 verbose stack     at rmStuff (/usr/local/lib/node_modules/npm/lib/unbuild.js:61:24)
7539 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
7539 verbose stack     at ret (eval at makeNodePromisifiedEval (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promisify.js:1:1), <anonymous>:13:39)
7539 verbose stack     at lifecycle.then.then (/usr/local/lib/node_modules/npm/lib/install/action/unbuild.js:12:12)
7539 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
7539 verbose stack     at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
7539 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
7539 verbose stack     at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
7539 verbose stack     at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
7539 verbose stack     at Async._drainQueue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
7539 verbose stack     at Async._drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
7539 verbose stack     at Immediate.Async.drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
7539 verbose stack     at runCallback (timers.js:672:20)
7539 verbose stack     at tryOnImmediate (timers.js:645:5)
7539 verbose stack     at processImmediate [as _immediateCallback] (timers.js:617:5)
7540 verbose cwd /Users/gigocabrera/Documents/ionic/CajaFuerte-app
7541 verbose Darwin 15.6.0
7542 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "@ionic/app-scripts@latest" "--save-dev"
7543 verbose node v7.10.0
7544 verbose npm  v5.3.0
7545 error Cannot read property '0' of undefined
7546 verbose exit [ 1, true ]
gigocabrera commented 7 years ago

This issue turned out to be related to npm 5.3.0. The issue below had a fix that worked for me https://github.com/ionic-team/ionic-app-scripts/issues/1039

GeeKanJi commented 7 years ago

(one month later :p) npm install npm@latest -g

npm 5.4.1 solved this issue

EDIT: Finally, 5.4.1 not working (another issue) npm install npm@5.0.3 -g (downgrade to 5.0.3 working)

qubiack commented 7 years ago

@jeromeXoo I have exactly the same problem like you, and when I use npm@5.0.3 downgrade it start working. Before I used 5.3.0 and update it to 5.4.1 but I get the same error.

Izhaki commented 6 years ago

This is a known, and rather odd, bug with npm: https://github.com/npm/npm/issues/17858

ORESoftware commented 6 years ago

F*cking NPM version 5 man, I have seen so many bugs with NPM version 5.x

starsinmypockets commented 6 years ago

++ the 5.0.3 downgrade kludge works for me as well. Thanks.

dagobit commented 6 years ago

Downgrade still works like a charm with old projects.