angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.64k stars 2.2k forks source link

error during deploy: Cannot find module 'triple-beam' #2534

Closed smarth55 closed 3 years ago

smarth55 commented 4 years ago

Version info

Angular: 10.0.1 Firebase: 7.15.5 AngularFire: 6.0.2 Other (e.g. Ionic/Cordova, Node, browser, operating system): node: 12.14.0

How to reproduce these conditions

I updated angular, material, and fire using the ng update command and then tried to run the deploy command.

Steps to set up and reproduce Here is the package.json file that I have after updating using the cli

{
  "name": "project",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.0.2",
    "@angular/cdk": "~10.0.1",
    "@angular/common": "~10.0.2",
    "@angular/compiler": "~10.0.2",
    "@angular/core": "~10.0.2",
    "@angular/fire": "^6.0.2",
    "@angular/forms": "~10.0.2",
    "@angular/material": "^10.0.1",
    "@angular/platform-browser": "~10.0.2",
    "@angular/platform-browser-dynamic": "~10.0.2",
    "@angular/router": "~10.0.2",
    "@angular/service-worker": "~10.0.2",
    "firebase": "7.15.5",
    "rxjs": "~6.5.4",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/architect": "0.801.1",
    "@angular-devkit/build-angular": "~0.1000.1",
    "@angular/cli": "~10.0.1",
    "@angular/compiler-cli": "~10.0.2",
    "@angular/language-service": "~10.0.2",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "firebase-tools": "^7.1.0",
    "fuzzy": "^0.1.3",
    "inquirer": "^6.5.0",
    "inquirer-autocomplete-prompt": "^1.0.1",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "^3.9.6"
  }
}

running npm install and then trying to use the @angualr/fire deploy command will result in the missing dependency error. It looks like https://github.com/angular/angularfire/blob/master/src/schematics/deploy/actions.ts#L245 is where this was added, but triple-beam is nowhere in the dependency tree. The addition of that code also assumes that winston is installed and it is because firebase lists it as a dep, but no mention of triple-beam.

Adding it manually fixes the issue. Actually, there is an additional error Cannot read property 'printf' of undefined caused by https://github.com/angular/angularfire/blob/master/src/schematics/deploy/actions.ts#L250. This looks to be because firebase-tools is requiring verison ^1.0.1 of winston and a newer version is not being required by @angular/fire.

Debug output

Cannot find module 'triple-beam'

Expected behavior

The build to be deployed

Actual behavior

console error: Cannot find module 'triple-beam'

smarth55 commented 4 years ago

So, I found that the reason the for the missing/weird dependancies is because firebase-tools was not updated. Odd too is that after updating using ng update @angular/fire, looking at the package.json for @angular/fire and looking in my package-lock.json, the only dependency listed is tslib.

From my lock file:

"@angular/fire": {
      "version": "6.0.2",
      "resolved": "https://registry.npmjs.org/@angular/fire/-/fire-6.0.2.tgz",
      "integrity": "sha512-r59v7XD2oNN1oJghRMcph+PVqJj49aQnQevArOU4ldW07K0t9k2Ud8ALO/z3iNvMOBkumenGlYSS/h3v4foLBg==",
      "requires": {
        "tslib": "^1.10.0"
      },
      "dependencies": {
        "tslib": {
          "version": "1.13.0",
          "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
          "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q=="
        }
      }
    }

And the generated package.json for @angular/fire in my node_modules:

{
  "$schema": "../node_modules/ng-packagr/package.schema.json",
  "_from": "@angular/fire@^6.0.2",
  "_id": "@angular/fire@6.0.2",
  "_inBundle": false,
  "_integrity": "sha512-r59v7XD2oNN1oJghRMcph+PVqJj49aQnQevArOU4ldW07K0t9k2Ud8ALO/z3iNvMOBkumenGlYSS/h3v4foLBg==",
  "_location": "/@angular/fire",
  "_phantomChildren": {},
  "_requested": {
    "type": "range",
    "registry": true,
    "raw": "@angular/fire@^6.0.2",
    "name": "@angular/fire",
    "escapedName": "@angular%2ffire",
    "scope": "@angular",
    "rawSpec": "^6.0.2",
    "saveSpec": null,
    "fetchSpec": "^6.0.2"
  },
  "_requiredBy": [
    "/"
  ],
  "_resolved": "https://registry.npmjs.org/@angular/fire/-/fire-6.0.2.tgz",
  "_shasum": "6c391128496f4fa16afba436a7a57a25e3e510f1",
  "_spec": "@angular/fire@^6.0.2",
  "_where": "path/to/project",
  "author": {
    "name": "angular,firebase"
  },
  "bugs": {
    "url": "https://github.com/angular/angularfire2/issues"
  },
  "builders": "./builders.json",
  "bundleDependencies": false,
  "dependencies": {
    "tslib": "^1.10.0"
  },
  "deprecated": false,
  "description": "The official library for Firebase and Angular",
  "es2015_ivy_ngcc": "__ivy_ngcc__/fesm2015/angular-fire.js",
  "es2015": "fesm2015/angular-fire.js",
  "esm2015": "esm2015/angular-fire.js",
  "fesm2015_ivy_ngcc": "__ivy_ngcc__/fesm2015/angular-fire.js",
  "fesm2015": "fesm2015/angular-fire.js",
  "homepage": "https://github.com/angular/angularfire2#readme",
  "keywords": [
    "angular",
    "firebase",
    "rxjs",
    "angularfire",
    "angularfire2"
  ],
  "license": "MIT",
  "main": "bundles/angular-fire.umd.js",
  "metadata": "angular-fire.metadata.json",
  "module_ivy_ngcc": "__ivy_ngcc__/fesm2015/angular-fire.js",
  "module": "fesm2015/angular-fire.js",
  "name": "@angular/fire",
  "peerDependencies": {
    "@angular/common": "^9.0.0 || ^10.0.0",
    "@angular/core": "^9.0.0 || ^10.0.0",
    "@angular/platform-browser": "^9.0.0 || ^10.0.0",
    "@angular/platform-browser-dynamic": "^9.0.0 || ^10.0.0",
    "firebase": "^7.13.1",
    "rxjs": "^6.5.3"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/angular/angularfire2.git"
  },
  "schematics": "./collection.json",
  "sideEffects": false,
  "typings": "angular-fire.d.ts",
  "version": "6.0.2",
  "__processed_by_ivy_ngcc__": {
    "es2015": "10.0.2",
    "fesm2015": "10.0.2",
    "module": "10.0.2",
    "typings": "10.0.2"
  },
  "scripts": {
    "prepublishOnly": "node --eval \"console.error('ERROR: Trying to publish a package that has been compiled by NGCC. This is not allowed.\\nPlease delete and rebuild the package, without compiling with NGCC, before attempting to publish.\\nNote that NGCC may have been run by importing this package into another project that is being built with Ivy enabled.\\n')\" && exit 1"
  }
}
lukfel commented 4 years ago

I also ran into this issue. Since I didn´t have the time for troubleshooting my workaround was directly running the following command in the console: ng build --prod && firebase deploy --only hosting

Alternatively, you can also add this command to your package.json like this:

"scripts": {
    "deploy-prod": "ng build --prod && firebase deploy --only hosting"
},

And then run npm run deploy-prod in the console.

jamesdaniels commented 3 years ago

Closing as there's a work around, def looks like a firebase-tools incompatibility to me. Hopefully these are mostly shaken out by now. Perhaps I should add a version check / warning...?