Angular-cli: Regression: project is not working anymore from 6.0.8 -> 6.1.0 (in lerna monorepos)

Created on 27 Jul 2018  ·  30Comments  ·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [x] all

Repro steps

Our angular/cli project ist located as one package of a larger lerna monorepo. We also make use of yarn workspaces, so all (or most) dependencies are hoisted within one single root node_modules folder. The resulting structure is something like

- node_modules <-- angular dependencies installed here
  - @angular
    - cli
    - core
    - ...
- packages
  - angular-app
    - package.json <-- angular dependencies defined here
    - src
    - ....
- package.json <-- no angular dependencies defined here

this line now (as of 6.1.0) prevents the project from working (at all) because relativePotential.startsWith('..') === true because in our structure relativePotential = ../../node_modules/@angular/core/package.json

everything was working fine with 6.0.8

The log given by the failure

You seem to not be depending on "@angular/core" and/or "rxjs". This is an error.

Desired functionality

I can work on my angular project with latest versions of everything

schematicupdate medium jira-sync broken bufix

Most helpful comment

Added to the top of our backlog

All 30 comments

Same setup - same issue here. Working on a workaround, I'll let you know if it works.

I have been playing around with combining lerna packages with angular worspace, so I would pull the angular.json and all related dependencies into the root package. Then the lerna packages would be semantically the same as the angular workspace libraries/applications. This would also "fix" this bug, as the angular project root would be equal to the lerna root. I am confident this will work (and will be cool)

However this is not something we can easily achieve in existing projects and I still see this as regression bug.

Same here. We have tried both Lerna and Rush.js, same result.

@hansl I am happy to create a PR for this issue. However, this is not really a bug in the code, more like a decision on how you check for dependencies. Is there anything I can do to speed this up?

maybe there is the need for a setting in angular.json to make clear what is considered to "be within the project"

still broken in 6.1.2

6.1.3 🤷‍♂️

Added to the top of our backlog

In the meantime, not ideal, but a quick fix on the lerna.json file to NOT hoist certain dependencies..

    "bootstrap": {
      "nohoist": [
        "@angular/*",
        "@angular-devkit/build-angular",
        "rxjs",
        "@ngtools/*"
      ]
    }

Actually, even this fix above is a nightmare as anything that is used by the UI needs to be set as a NOHOIST ...... So its a lot of packages. Anybody find an alternative fix ?

I am using 6.1.5 (installed today).

@appsolutegeek try to add your dependencies in the root package.json. Then you will be able to hoist the dependencies within your packages.

I'm having the same issue, with only using Yarn workspaces. The nohoist option in package.json is indeed a fair temporary fix (thanks @appsolutegeek!) - hopefully this' will be fixed in the future.

@gombosg no problem, hopefully, we can update the cli soon, so I can remove the NO HOIST packages.

sadly, the nohoist option is only available for private packages

also sadly

Added to the top of our backlog

does not seem to mean "this is the very next issue that gets fixed"

6.2.0, 7.0.0 😔

Is there any update when the issue will be fixed?

@hansl 👍

wait a minute, why did this not land in 6.2.4 ???

@ctaepper It seems that it went in 7.0.0-rc. Updating only @angular/cli worked for me.

@alexeagle, @hansl, could we also have the fix on 6.2.x please? Moving to 7.0.0-rc* creates other problems with dependencies that are not ready for 7.0...

Hi there, anyone tested monorepo approach with Firebase Cloud Functions ?

The idea: multiple apps for multiple Firebase targets, hosted via Firebase hosting. Each target would be a subdomain. I manage to do that.

But I'm struggling with Firebase Cloud Functions setup to be OK in the monorepo. It just doesn't work for now. Do you have best practices to share ?

@johanchouquet I have an angular monorepo with multiple firebase projects in it, including a firebase functions project. I can confirm it works fine.

@thefliik , I'm so glad to hear that it can work.

Then, i have this structure. I created 3 apps with the CLI. So my project structure is:

| projects
  | admin
  | app
  | website
package.json
| node_modules
| functions
  | package.json
  | node_modules
.firebaserc
firebase.json

Everything is standard there. When I do firebase deploy --only functions, it fails when executing the tsc task.
I've this stacktrace:

node_modules/@google-cloud/common/node_modules/gaxios/build/src/index.d.ts(14,66): error TS1005: '>' expected.
node_modules/@google-cloud/common/node_modules/gaxios/build/src/index.d.ts(14,103): error TS1109: Expression expected.
node_modules/firebase-functions/lib/function-builder.d.ts(58,93): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(58,94): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(58,114): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,88): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,89): error TS1003: Identifier expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,109): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,110): error TS1131: Property or signature expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,127): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,184): error TS1109: Expression expected.
node_modules/firebase-functions/lib/function-builder.d.ts(63,229): error TS1005: '(' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(64,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(65,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(99,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(117,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(124,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(131,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(138,146): error TS1005: '(' expected.
node_modules/firebase-functions/lib/function-builder.d.ts(140,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(153,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(162,5): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-builder.d.ts(168,1): error TS1128: Declaration or statement expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(4,64): error TS1005: ']' expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(4,66): error TS1134: Variable declaration expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(4,153): error TS1005: ';' expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(16,61): error TS1005: ']' expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(16,63): error TS1134: Variable declaration expected.
node_modules/firebase-functions/lib/function-configuration.d.ts(16,93): error TS1005: ';' expected.

I'm not sure if i don't something wrong or anything. I'm using the latest dependencies in the functions/package.json, as follow:

"dependencies": {
    "firebase-admin": "~8.2.0",
    "firebase-functions": "^3.1.0"
  }

So, did you configure something to make Firebase Cloud Functions work fine in the monorepo ?

@johanchouquet it's been a while since I set it up, so I can't remember if I encountered any issues in the beginning.

My folder structure is like so

> apps
  > app_one_name
    > app
    > e2e
    package.json
  > functions
    > src
    > tasks
    package.json
    tsconfig.json
    // ...
  > // ...
> libs
  > lib_one
  > lib_two
  > // ...
.firebaserc
angular.json
firebase.json
package.json
tsconfig.json
// ...

It's set up using yarn with yarn workspaces. The workspace's package.json includes:

{
  "workspaces": {
    "packages": [
      "apps/*",
      "libs/*"
    ]
  }
}

The only other thing of note is that the firebase.json file needs to specify the location of the functions source directory:

{
  "functions": {
    "source": "apps/functions"
  }
}

This all being said, your error message looks like it's coming from a syntax error in a typings file. Have you examined the file causing the error? Looks like it could be caused by an incorrect typescript version. Or perhaps the typings for dependencies are clashing in some way.

_🤔 💭 It's times like these I wish github had some sort of direct messaging system, to avoid cluttering issues._

Thanks @thefliik.

🤔 💭 It's times like these I wish github had some sort of direct messaging system, to avoid cluttering issues.

So true ^^!

This all being said, your error message looks like it's coming from a syntax error in a typings file. Have you examined the file causing the error? Looks like it could be caused by an incorrect typescript version. Or perhaps the typings for dependencies are clashing in some way.

I'm looking into this right now.

I've created my workspace using Angular Console. So I didn't expect that there would be issues in typescript versions or else. Maybe this is not related, but just saying. BTW, AngularConsole is really amazing.

I'll look into yarn workspaces. Seems to be simpler to deal with Cloud Functions.

@johanchouquet sometimes typescript version errors can be hidden by vscode. VSCode, so long as it is kept updated, seems to always use the latest typescript version for intellisense. If your project has an older version of typescript installed, this means that vscode may not show you errors if you accidentally use a typescript feature that is newer than the typescript version your project is using (or if you depend on a library which, in turn, depends on a newer typescript version than you are using).

For example, a firebase functions project of mine was using typescript ~3.2. But I accidentally pulled in a library which made use of the new readonly Array<T> and as const syntax introduced in typescript 3.4. The error showed up as a strange syntax error at compile time. VSCode understood the syntax (because it was using typescript 3.5 to power intellisense), but the version of typescript using during compilation did not. The version of typescript used during compilation didn't even know how to define the error really. It said something like "variable declaration expected" or "unexpected [".

@thefliik , indeed, my tsc version was 3.1.6 in VS Code terminal ! I managed to change it to the same version used in my projects (v3.4.5). But nothing changed: i still have those errors... Very strange behavior.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NCC1701M picture NCC1701M  ·  3Comments

brtnshrdr picture brtnshrdr  ·  3Comments

rajjejosefsson picture rajjejosefsson  ·  3Comments

naveedahmed1 picture naveedahmed1  ·  3Comments

donaldallen picture donaldallen  ·  3Comments