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

Ionic setup fails out of the box / Compile error: Cannot redeclare block-scoped variable __DEBUG_BUILD__ #394

Closed
zarko-tg opened this issue Jun 22, 2023 · 13 comments

Comments

@zarko-tg
Copy link

Environment

Following the instructions from https://docs.sentry.io/platforms/javascript/guides/capacitor/ionic/

Node 18.16.1
macOS Ventura 13.4.1
Installed global @ionic/cli@7.1.1

Steps to Reproduce

  1. Created a fresh Ionic 7 / Angular 16 / Capacitor 5 project using "ionic start".
  2. Followed the instructions from the docs link above.
  3. ionic serve

Yields:

[ng] Error: node_modules/@sentry/capacitor/node_modules/@sentry/types/types/globals.d.ts:2:11 - error TS2451: Cannot redeclare block-scoped variable '__DEBUG_BUILD__'.
[ng]
[ng] 2     const __DEBUG_BUILD__: boolean;
[ng]             ~~~~~~~~~~~~~~~
[ng]
[ng]   node_modules/@sentry/types/types/globals.d.ts:2:11
[ng]     2     const __DEBUG_BUILD__: boolean;
[ng]                 ~~~~~~~~~~~~~~~
[ng]     '__DEBUG_BUILD__' was also declared here.
[ng]
[ng]
[ng] Error: node_modules/@sentry/types/types/globals.d.ts:2:11 - error TS2451: Cannot redeclare block-scoped variable '__DEBUG_BUILD__'.
[ng]
[ng] 2     const __DEBUG_BUILD__: boolean;
[ng]             ~~~~~~~~~~~~~~~
[ng]
[ng]   node_modules/@sentry/capacitor/node_modules/@sentry/types/types/globals.d.ts:2:11
[ng]     2     const __DEBUG_BUILD__: boolean;
[ng]                 ~~~~~~~~~~~~~~~
[ng]     '__DEBUG_BUILD__' was also declared here.

sentest.zip

Attached you can find a reproduction project, where after unpacking you just run: npm i && ionic serve

@lforst
Copy link
Member

lforst commented Jun 22, 2023

This needs to be fixed upstream. #249

@g-apparence
Copy link

Adding "@sentry/types": "7.56.0" to the package.json fixed it for me.

@lucas-zimerman
Copy link
Collaborator

You need to alter your package.json

    "@sentry/angular-ivy": "^7.56.0",
    "@sentry/capacitor": "^0.12.1",

to

    "@sentry/angular-ivy": "7.56.0",
    "@sentry/capacitor": "0.12.1",

Sentry Capacitor has conflicts if a sibling package reference has a caret symbol.

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@zVynx
Copy link

zVynx commented Sep 11, 2023

I cant fix the issue my package.json looks like this:

"@sentry/angular-ivy": "7.56.0",
"@sentry/capacitor": "0.12.1",
"@sentry/types": "7.56.0",

i am using ionic 7.3.2 and capacitore core ^5.0.0 has anyone found a fix for this Bug?

@zVynx
Copy link

zVynx commented Sep 11, 2023

Nvm I got it working using

"@sentry/angular-ivy": "7.54.0",
"@sentry/capacitor": "0.12.1",

@Sampath-Lokuge
Copy link

Sampath-Lokuge commented Sep 13, 2023

Still the same error with the latest versions:

Error: node_modules/@sentry/capacitor/node_modules/@sentry/types/types/globals.d.ts:2:11 - error TS2451: Cannot redeclare block-scoped 
variable '__DEBUG_BUILD__'.

2     const __DEBUG_BUILD__: boolean;
            ~~~~~~~~~~~~~~~

  node_modules/@sentry/types/types/globals.d.ts:2:11
    2     const __DEBUG_BUILD__: boolean;
                ~~~~~~~~~~~~~~~
    '__DEBUG_BUILD__' was also declared here.


Error: node_modules/@sentry/types/types/globals.d.ts:2:11 - error TS2451: Cannot redeclare block-scoped variable '__DEBUG_BUILD__'.    

2     const __DEBUG_BUILD__: boolean;
            ~~~~~~~~~~~~~~~

  node_modules/@sentry/capacitor/node_modules/@sentry/types/types/globals.d.ts:2:11
    2     const __DEBUG_BUILD__: boolean;
                ~~~~~~~~~~~~~~~
    '__DEBUG_BUILD__' was also declared here.

package.json

{
  "name": "",
  "version": "1.5.23",
  "author": "",
  "homepage": "",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/cdk": "16.2.3",
    "@angular/common": "16.2.4",
    "@angular/core": "16.2.4",
    "@angular/forms": "16.2.4",
    "@angular/platform-browser": "16.2.4",
    "@angular/platform-browser-dynamic": "16.2.4",
    "@angular/router": "16.2.4",
    "@capacitor-community/sqlite": "5.2.3",
    "@capacitor-firebase/authentication": "5.1.0",
    "@capacitor/android": "5.0.0",
    "@capacitor/app": "5.0.0",
    "@capacitor/camera": "5.0.0",
    "@capacitor/core": "5.0.0",
    "@capacitor/haptics": "5.0.0",
    "@capacitor/ios": "5.0.0",
    "@capacitor/keyboard": "5.0.0",
    "@capacitor/network": "5.0.0",
    "@capacitor/preferences": "5.0.0",
    "@capacitor/splash-screen": "5.0.0",
    "@capacitor/status-bar": "5.0.0",
    "@ionic/angular": "7.3.4",
    "@sentry/angular-ivy": "7.69.0",
    "@sentry/capacitor": "0.12.3",
    "@sentry/types": "7.69.0",
    "@types/lodash": "4.14.178",
    "dayjs": "1.10.7",
    "firebase": "9.6.10",
    "guid-typescript": "1.0.9",
    "lodash": "4.17.21",
    "rxjs": "7.5.0",
    "tslib": "2.2.0",
    "zone.js": "0.13.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "16.2.2",
    "@angular-eslint/builder": "16.1.2",
    "@angular-eslint/eslint-plugin": "16.1.2",
    "@angular-eslint/eslint-plugin-template": "16.1.2",
    "@angular-eslint/template-parser": "16.1.2",
    "@angular/cli": "16.2.2",
    "@angular/compiler": "16.2.4",
    "@angular/compiler-cli": "16.2.4",
    "@angular/language-service": "16.2.4",
    "@capacitor/cli": "5.0.0",
    "@ionic/angular-toolkit": "^9.0.0",
    "@sentry/cli": "2.20.7",
    "@types/node": "12.11.1",
    "@typescript-eslint/eslint-plugin": "6.7.0",
    "@typescript-eslint/parser": "6.7.0",
    "eslint": "8.49.0",
    "eslint-plugin-import": "2.28.1",
    "eslint-plugin-jsdoc": "46.6.0",
    "eslint-plugin-prefer-arrow": "1.2.3",
    "prettier": "2.5.1",
    "ts-node": "8.3.0",
    "typescript": "4.9.5"
  },
  "description": ""
}

@BillBu
Copy link

BillBu commented Sep 26, 2023

Previously working but now reintroduced with the following in package.json:
"@sentry/angular-ivy": "^7.71.0",
"@sentry/capacitor": "^0.13.0-beta.1",

@Sampath-Lokuge
Copy link

@BillBu Until they'll fix this you can try this:

"@sentry/angular-ivy": "7.54.0",
"@sentry/capacitor": "0.12.1",

@BillBu
Copy link

BillBu commented Sep 26, 2023

@BillBu Until they'll fix this you can try this:

"@sentry/angular-ivy": "7.54.0",
"@sentry/capacitor": "0.12.1",

Thanks, but we need to use the 0.13 version because it fixes the issue where iOS is initialized on a background thread, which causes our app to crash. So we have to use that version (or at least get to the point where we can test it to see if it works).

I've uninstalled @sentry/angular-ivy and just referencing

import * as SentryAngular from '@sentry/angular';

instead of

import * as SentryAngular from '@sentry/angular-ivy';

And that compiles okay. Not sure what the effect of that is though and if that causes any other problems.

@Sampath-Lokuge
Copy link

@BillBu

import * as SentryAngular from '@sentry/angular';

The problem is this:

Important: This package is not compatible with Angular 16 or newer. Please use @sentry/angular-ivy instead.

Ref: https://www.npmjs.com/package/@sentry/angular#angular-version-compatibility

@BillBu
Copy link

BillBu commented Sep 26, 2023

Thanks, having to revert to 0.12 until this DEBUG_BUILD issue is fixed for 0.13.

@lucas-zimerman
Copy link
Collaborator

If you still are having this issue on the next release please let us know, for the time being I am closing this issue, thanks for opening it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

7 participants