question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transpile error after import capacitor/core

See original GitHub issue

Description of the problem: I get a transpile error after import capacitor/core in the app.component.ts

Error:

Thomass-Mac-Pro:quest thomas$ ionic build

ionic-app-scripts build [15:14:32] ionic-app-scripts 3.2.2 [15:14:32] build dev started … [15:14:32] clean started … [15:14:32] clean finished in 5 ms [15:14:32] copy started … [15:14:32] deeplinks started … [15:14:32] deeplinks finished in 31 ms [15:14:32] transpile started … [15:14:37] typescript: node_modules/@capacitor/core/dist/esm/global.d.ts, line: 3 ‘=’ expected.

   L2:  declare var Capacitor: _Capacitor;
   L3:  declare const Plugins: import("./core-plugin-definitions").PluginRegistry;
   L4:  export { Capacitor, Plugins };

[15:14:37] typescript: node_modules/@capacitor/core/dist/esm/global.d.ts, line: 3 Cannot find name ‘import’.

   L2:  declare var Capacitor: _Capacitor;
   L3:  declare const Plugins: import("./core-plugin-definitions").PluginRegistry;
   L4:  export { Capacitor, Plugins };

[15:14:37] typescript: node_modules/@capacitor/core/dist/esm/global.d.ts, line: 3 Property ‘PluginRegistry’ does not exist on type ‘“./core-plugin-definitions”’.

   L2:  declare var Capacitor: _Capacitor;
   L3:  declare const Plugins: import("./core-plugin-definitions").PluginRegistry;
   L4:  export { Capacitor, Plugins };

[15:14:37] ionic-app-script task: “build” [15:14:37] Error: Failed to transpile program Error: Failed to transpile program at new BuildError (/Users/thomas/Documents/Again/quest/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28) at /Users/thomas/Documents/Again/quest/node_modules/@ionic/app-scripts/dist/transpile.js:159:20 at new Promise (<anonymous>) at transpileWorker (/Users/thomas/Documents/Again/quest/node_modules/@ionic/app-scripts/dist/transpile.js:107:12) at Object.transpile (/Users/thomas/Documents/Again/quest/node_modules/@ionic/app-scripts/dist/transpile.js:64:12) at /Users/thomas/Documents/Again/quest/node_modules/@ionic/app-scripts/dist/build.js:109:82 [ERROR] An error occurred while running subprocess ionic-app-scripts.

    ionic-app-scripts build exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

Affected platform

  • Android
  • iOS
  • electron
  • web

OS of the development machine

  • Windows
  • macOS
  • linux

Other information: package.json file:

{
  "name": "quest",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@capacitor/android": "^1.0.0-beta.25",
    "@capacitor/cli": "1.0.0-beta.25",
    "@capacitor/core": "^1.0.0-beta.25",
    "@capacitor/ios": "^1.0.0-beta.25",
    "@ionic-native/core": "~4.20.0",
    "@ionic-native/splash-screen": "~4.20.0",
    "@ionic-native/status-bar": "~4.20.0",
    "@ionic/storage": "2.2.0",
    "ionic-angular": "3.9.5",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.29"
  },
  "devDependencies": {
    "@ionic/app-scripts": "3.2.2",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project"
}

Capacitor version: 1.0.0-beta.25

node version: 10.15.3

npm version: 6.4.1

Steps to reproduce:

  1. ionic start quest blank --type=ionic-angular --capacitor
  2. ionic build
  3. npx cap copy
  4. add import { Plugins } from ‘@capacitor/core’; to app.component.ts
  5. ionic build

Fully ionic info:

Ionic:

ionic (Ionic CLI) : 4.12.0 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic-angular 3.9.5 @ionic/app-scripts : 3.2.2

Capacitor:

capacitor (Capacitor CLI) : 1.0.0-beta.25 @capacitor/core : 1.0.0-beta.25

System:

NodeJS : v10.15.3 (/usr/local/bin/node) npm : 6.4.1 OS : macOS High Sierra

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:29 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
CarlosFJcommented, Nov 6, 2019

In Plugins -> global.d.ts This work for me

import { Capacitor as _Capacitor } from ‘./definitions’; import * as _Plugins from “./core-plugin-definitions”; declare const Capacitor: _Capacitor;

declare const Plugins: _Plugins.PluginRegistry; export { Capacitor, Plugins };

6reactions
jcesarmobilecommented, May 18, 2019

Try updating typescript to 2.9 or newer

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript: node_modules/@capacitor/core/dist/esm/global.d.ts
Hi, i have installed capacitor for using google maps component. It's ok on test server ionic “ionic serve” with some time this message:....
Read more >
error building `ionic-angular` app with `capacitor`
I get the following error AFTER I add capacitor the the project: ... /gmap3/node_modules/@ionic/app-scripts/dist/transpile.js:159:20 at new ...
Read more >
Ionic Error Logging with Sentry using Capacitor - YouTube
Learn to integrate Sentry.io in your Ionic application to setup error logging for Ionic and Capacitor apps! Learn Ionic faster with...
Read more >
@capacitor/core - npm
Start using @capacitor/core in your project by running `npm i ... There are 1167 other projects in the npm registry using @capacitor/core.
Read more >
task :capacitor-cordova-android-plugins ... - You.com
Task :capacitor-android:compileDebugAidl NO-SOURCE Relying on FileTrees for ignoring empty ... ionic error: cannot find symbol import org.apache.cordova.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found