Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on build with mergeDeep #4506

Closed
harishajdarevic opened this issue Feb 27, 2019 · 20 comments
Closed

Bug on build with mergeDeep #4506

harishajdarevic opened this issue Feb 27, 2019 · 20 comments

Comments

@harishajdarevic
Copy link

Intended outcome:

Here are version of packages that I'm using:

    "apollo-angular": "1.0.1",
    "apollo-angular-link-http": "1.0.1",
    "apollo-cache-inmemory": "1.3.9",
    "apollo-client": "2.4.5",
    "apollo-link": "1.2.3",
    "apollo-link-context": "1.0.9",
    "apollo-link-http": "1.5.5",

Actual outcome:

Running ng build produces

node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,214): error TS1005: ',' expected.

@benjamn
Copy link
Member

benjamn commented Feb 27, 2019

Can you share a runnable reproduction? It's hard to guess what Angular might be complaining about, otherwise.

@benjamn
Copy link
Member

benjamn commented Feb 27, 2019

Possibly related (not exactly the same error, but I suspect Angular's requirement of TypeScript 2 could be the root of your problems, too): #4475

@soniachan
Copy link

soniachan commented Feb 28, 2019

I am also hitting this error suddenly...

"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.9",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@okta/okta-auth-js": "^1.14.0",
"@types/jquery": "^3.3.1",
"apollo-angular": "1.0.1",
"apollo-angular-link-http": "1.0.2",
"apollo-utilities": "1.0.23",
"apollo-cache": "1.1.9",
"apollo-cache-inmemory": "1.1.11",
"apollo-client": "2.2.7",
"apollo-link-context": "1.0.8",
"apollo-link-error": "1.1.0",
"apollo-link-ws": "1.0.8",
"class-transformer": "0.1.9",
"core-js": "^2.4.1",
"graphql": "0.13.2",
"graphql-tag": "2.8.0",
"jquery": "^3.3.1",
"mime-types": "^2.1.18",
"ng2-fancy-image-uploader": "2.0.1",
"ngx-avatar": "^2.9.0",
"ngx-bootstrap": "^2.0.3",
"ngx-dropdown": "0.0.22",
"reflect-metadata": "^0.1.12",
"rxjs": "^5.5.6",
"subscriptions-transport-ws": "^0.9.8",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.3",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-allure-reporter": "^1.0.2",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3",
"forever": "^0.15.3"
}

14:58:16 [exec] > ng build --environment $ENVIRONMENT
14:58:16 [exec]
14:58:21 [exec] Date: 2019-02-28T06:58:21.070Z
14:58:21 [exec] Hash: 05a54b3e5a8167a47851
14:58:21 [exec] Time: 2441ms
14:58:21 [exec] chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 3.89 kB [entry] [rendered]
14:58:21 [exec] chunk {main} main.bundle.js, main.bundle.js.map (main) 277 bytes [initial] [rendered]
14:58:21 [exec] chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 297 bytes [initial] [rendered]
14:58:21 [exec]
14:58:21 [exec] ERROR in node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,62): error TS1005: ';' expected.
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,77): error TS1005: ',' expected.
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,88): error TS1005: ';' expected.chunk {scripts} scripts.bundle.js, scripts.bundle.js.map (scripts) 517 kB [initial] [rendered]
14:58:21 [exec]
14:58:21 [exec] chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 355 kB [initial] [rendered]
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,103): error TS1005: ',' expected.
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,112): error TS1005: ',' expected.
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,127): error TS1005: ';' expected.
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,142): error TS1005: ',' expected.
14:58:21 [exec] node_modules/graphql-anywhere/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(1,151): error TS1005: ',' expected.

@benjamn
Copy link
Member

benjamn commented Feb 28, 2019

@soniachan You're using a fairly old version of typescript (2.5.3). Another user reported that the problem went away after updating Angular CLI and typescript: #4501 (comment)

@benjamn
Copy link
Member

benjamn commented Feb 28, 2019

If you're not able to update typescript, you might be able to disable type checking for apollo-utilities specifically, or node_modules in general. I'm not sure exactly how that would work in an Angular project, but it seems like it should be feasible.

@netresource
Copy link

I had the same issue with Angular global latest 7.x and local is 5.2.11.
@benjamn how to disable type checking for apollo-utilities?
Thanks!

@soniachan
Copy link

@soniachan You're using a fairly old version of typescript (2.5.3). Another user reported that the problem went away after updating Angular CLI and typescript: #4501 (comment)

Upgrading Angular and typescript worked for me!! :)

"@angular/core": "6.1.10",
"@angular/cli": "6.2.5",
"apollo-utilities": "1.0.21",
"typescript": "2.8.4"

@ahelord
Copy link

ahelord commented Mar 6, 2019

i get same error

{
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"dev:start": "nodemon start_server.js",
"start:api": "ng serve --proxy-config proxy.conf.json",
"prod:build": "./node_modules/.bin/ng build --prod",
"prod:start": "node ./node_modules/.bin/pm2 start start_server.js -i max --name app"
},
"private": true,
"dependencies": {
"@angular/animations": "5.2.0",
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.0",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"angular-ui-carousel": "0.1.10",
"apollo-angular": "1.0.1",
"apollo-angular-link-http": "1.0.3",
"apollo-cache-inmemory": "1.3.0",
"apollo-client": "2.3.1",
"body-parser": "1.18.2",
"classlist.js": "1.1.20150312",
"concurrently": "3.5.1",
"core-js": "2.4.1",
"express": "4.16.3",
"express-graphql": "0.6.12",
"font-awesome": "4.7.0",
"graphql": "0.13.2",
"graphql-compose": "4.3.0",
"graphql-compose-mongoose": "4.1.1",
"graphql-tag": "2.9.2",
"helmet": "3.12.1",
"moment": "2.22.1",
"mongoose": "5.0.14",
"mongoose-data-seed": "1.0.5",
"morgan": "1.9.0",
"ng2-validation": "4.2.0",
"node-sass": "4.8.3",
"nodemon": "1.17.4",
"pm2": "2.10.4",
"primeng": "5.2.4",
"pug": "2.0.3",
"rxjs": "5.5.6",
"serve-favicon": "2.5.0",
"ui-carousel": "0.2.0",
"web-animations-js": "2.3.1",
"zone.js": "0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.3",
"@angular/compiler-cli": "5.2.0",
"@angular/language-service": "5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}

@darmie
Copy link

darmie commented Mar 6, 2019

This is still an issue

@ahelord
Copy link

ahelord commented Mar 6, 2019

@soniachan
you can send the complete package.json

@benjamn
Copy link
Member

benjamn commented Mar 6, 2019

Folks, please read the existing comments before posting the same information again. Updating typescript to version 3.0.0 or higher has fixed this problem for others. If that's not an option, I'd like to understand what's holding you back, so that we can weigh our options. Commenting that you have the same problem is not helpful at this point. Thanks.

@soniachan
Copy link

@soniachan
you can send the complete package.json

the error happen again today... i will try upgrade the versions again

11:25:40 [exec] ERROR in node_modules/apollo-link/node_modules/apollo-utilities/lib/util/mergeDeep.d.ts(2,52): error TS2370: A rest parameter must be of an array type. 11:25:40 [exec] 11:25:40 [exec]

@alexander-kovalev
Copy link

alexander-kovalev commented Mar 7, 2019

@harishajdarevic I tried to set specific version of "apollo-link": "1.2.3", "apollo-utilities": "1.0.22", and it worked for me. Compiled without errors.

@thekevinbrown
Copy link

thekevinbrown commented Mar 8, 2019

@benjamn I'm seeing this error with typescript v3.3.3333.

Edit: Actually, I'm using Typescript v3.3.3333, but a package has a dependency instead of a peer dependency, pinning the version at 2.2. So it's not actually running Typescript 3 for me:

https://github.com/prisma/serverless-plugin-typescript/blob/master/package.json

So, ignore this, it's not actually happening in v3.

@mattezell
Copy link

+1

Wanted to share my observations in case it assists others. A little back story: we have a large enterprise application codebase that was working, but seemingly breaks following running an 'npm install' - error is the reported deepMerge. We can't currently migrate to Angular 7, and Angular 6 of course doesn't support TypeScript 3... So we find ourselves having to find a workaround until we can tackle migration - which is unfortunate. I am sharing this in case it assists others to avoid wasting 2 days.

Our project's relevant dependencies from package.json:

    "@angular/animations": "6.1.0",
    "@angular/cdk": "6.4.2",
    "@angular/common": "6.1.0",
    "@angular/compiler": "6.1.0",
    "@angular/core": "6.1.0",
    "@angular/elements": "6.1.7",
    "@angular/forms": "6.1.0",
    "@angular/http": "6.1.0",
    "@angular/platform-browser": "6.1.0",
    "@angular/platform-browser-dynamic": "6.1.0",
    "@angular/pwa": "0.8.0",
    "@angular/router": "6.1.0",
    "@angular/service-worker": "6.1.7",
    "apollo-angular": "1.5.0",
    "apollo-angular-link-http": "1.4.0",
    "apollo-cache-inmemory": "1.4.2",
    "apollo-client": "2.4.12",
    "apollo-link-error": "1.1.5",
    "apollo-link-retry": "2.2.8",
    "graphql": "14.1.1",
    "graphql-tag": "2.10.1"

Our project's relevant dev dependencies from package.json:

    "@angular-devkit/build-angular": "0.6.8",
    "@angular-devkit/build-ng-packagr": "0.6.8",
    "@angular/cli": "7.3.0",
    "@angular/compiler-cli": "6.1.0"

Node/NPM:

node: v10.15.0
npm: 6.4.1

I've found two workarounds that get us building, though we have yet to do the testing that will be needed to vet if this is actually a workable solution (e.g. everything behaving at runtime)... In any case, either of the following will get us building again:

  • Remove all of the nested '\apollo-*\node_modules' (many of the apollo libs have nested node_modules, mostly for the 3 apollo-utilities versions currently in play).
  • Replace the nested '\apollo-*\node_modules\apollo-utilities' with an older version (I've tested 1.0.22)

As mentioned, performing either of the above in our codebase results in a working build.

As mentioned, I've tracked down 3 versions of apollo-utilities at play within the various nested node_modules: 1.2.1, 1.0.22, 1.1.2.

For the interested, here is what I am seeing when I inspect the package-lock.json following npm install:

Packge: apollo-cache@1.2.1
Requires: apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-cache-inmemory@1.4.2
Requires: apollo-utilities@^1.1.2
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-client@2.4.12
Requires: apollo-utilities@^1.1.2
Resolved: apollo-utilities@1.1.2
------------
Packge: apollo-link@1.2.3
Requires: apollo-utilities@^1.0.0
Resolved: <No Dependencies Obj Present>
------------
Packge: apollo-link-dedup@1.0.16
Requires: apollo-link@^1.2.9 > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-link-error@1.1.5
Requires: apollo-link@^1.2.9 > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-link-http-common@0.2.11
Requires: apollo-link@^1.2.9 > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-link-retry@2.2.8
Requires: apollo-link@^1.2.6 (resolves 1.2.9) > apollo-utilities@^1.2.1
Resolved: apollo-utilities@1.2.1
------------
Packge: apollo-utilities@1.0.22
Requires: <NA - This is top node_modules install>
Resolved: apollo-utilities@1.0.22
------------

@mattezell
Copy link

Any movement on this? This continues to plague our projects and the manual work arounds that I've described are somewhat cumbersome and not really manageable...

@evanjmg
Copy link

evanjmg commented May 22, 2019

I have an Angular 5, TypeScript 2.4 project that can't get around this. Tried overriding types etc and it would break Angular module imports. So I just went with this library - https://github.com/prisma/graphql-request

@joshstrange
Copy link

joshstrange commented Jun 4, 2019

Ok I can't promise this will fix it for you but I was able to get this working. I am running the following versions of things (yes I know this thread is not about ionic/cordova but that is what I'm using so I'm listing those versions if it helps someone else):

NPM

ionic (Ionic CLI)  : 4.0.5
Ionic Framework    : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.11
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms     : android 7.1.1, ios 4.5.5
angular: 5.2.11
typescript: 2.4.2

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.4
ios-sim           : 8.0.1
NodeJS            : v8.11.3 (/usr/local/bin/node)
npm               : 6.7.0
OS                : macOS
Xcode             : Xcode 10.1 Build version 10B61

I had to "hoist" a number of apollo dependencies up to my package.json in order to lock them at versions that would be compatible with apollo-utilities@1.0.12 here is what my final package.json looks like (only apollo-related):

"apollo-angular": "1.0.1",
"apollo-angular-link-http": "1.0.1",
"apollo-cache": "1.1.8",
"apollo-cache-inmemory": "1.2.1",
"apollo-client": "2.3.1",
"apollo-link": "1.2.2",
"apollo-link-context": "1.0.8",
"apollo-link-dedup": "^1.0.9",
"apollo-utilities": "1.0.12",
"graphql": "0.13.2",
"graphql-anywhere": "^4.1.10",
"graphql-tag": "2.9.2",

I also had another issue with typescript that required I lock typeorm at a lower version:

"typeorm": "0.2.6",

Not sure if that will help anyone but after spending almost 2 days on this mess I thought I'd add it.

I am not saying this WILL work for you and I know some of those versions could probably be bumped a little higher but I got them from another ionic/angular project that I work on that had not been updated (npm install from scratch or npm update) in some time.

Lastly I could have fixed this without looking at a working project but tracking down everything that required the problem library (apollo-utilities) and looking at their github/versions to find out at which point they started using a >1.0.12 apollo-utilities and use the last good version before then.

Parting words: I really hate npm's ^ and ~ they lead to WAY more heartache than they "solve" and they make assumptions about other people's use of semvar that has time and time again proven demonstratively false. Everyone should pin versions of their dependencies at specific versions instead of blindly assuming that if 1.0.0 worked then 1.0.1 should be fine (or 1.0.0 -> 1.1.0 in the case of ^). This doesn't solve the problem I ran into here (when a dependency you have locked is using a ^ or ~ for IT's dependencies) but with "hoisting" like I did (bringing a nested dep to the top level) you can at least work around it.

@JustEugen
Copy link

JustEugen commented Sep 24, 2019

As a temporary solution, you can install older version.

@hwillson
Copy link
Member

This no longer sounds like an Apollo Client issue, but if anyone thinks it is and can provide a small runnable reproduction using @apollo/client@latest, we'll take a look. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests