【问题标题】:Nativescript-angular:: TypeError: Class constructor View cannot be invoked without 'new' while using nativescript-youtubeplayer npm packageNativescript-angular:: TypeError:在使用 nativescript-youtubeplayer npm 包时,如果没有“new”,就无法调用类构造函数视图
【发布时间】:2021-02-07 05:40:29
【问题描述】:

我想使用 nativescript-youtubeplayer / nativescript-youtubeplayer-inline npm 包在我的 nativescript-angular 移动应用中播放 youtube 视频。我已按照https://www.npmjs.com/package/nativescript-youtubeplayer 提供的步骤进行操作 当我尝试使用 tns run android --bundle 命令构建我的应用程序时,我遇到了以下错误..

*JS: ERROR Error: Uncaught (in promise): TypeError: Class constructor View cannot be invoked without 'new'
JS: TypeError: Class constructor View cannot be invoked without 'new'
JS: at new YoutubePlayerBase (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:154484:42)
JS: at new YoutubePlayer (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:154511:1)
JS: at ViewUtil.createView (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:93506:22)
JS: at NativeScriptRenderer.createElement (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:93706:30)
JS: at elementCreate (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:50479:25)
JS: at ɵɵelementStart (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:58110:43)
JS: at Module.ɵɵelement (file:///data/user/0/org.nativescript.nsngsample/files/app/vendor.js:58187:5)
JS: at AppTabsComponent_Template (file:///data/user/0/org.nativescript.nsngsample/files/app/bundle.js:138:64)...*

请在下面找到我的项目详细信息:

 Angular CLI: 10.2.0
    Node: 12.19.0
    OS: win32 x64
    
    Angular: 10.1.6
    ... animations, common, compiler, compiler-cli, core, forms
    ... platform-browser, platform-browser-dynamic, router
    Ivy Workspace: Yes

Package Version

@angular-devkit/architect 0.1002.0
@angular-devkit/core 10.2.0
@angular-devkit/schematics 10.2.0
@angular/cli 10.2.0
@ngtools/webpack 10.1.7
@schematics/angular 10.2.0
@schematics/update 0.1002.0
rxjs 6.6.3
typescript 3.9.7

Package.json:

{
"name": "@nativescript/template-hello-world-ng",
"main": "main.js",
"version": "7.0.2",
"author": "NativeScript Team oss@nativescript.org",
"description": "NativeScript Application",
"license": "SEE LICENSE IN ",
"publishConfig": {
"access": "public"
},
"keywords": [
"nativescript",
"mobile",
"angular",
"{N}",
"template"
],
"repository": "",
"bugs": {
"url": "https://github.com/NativeScript/NativeScript/issues"
},
"scripts": {
"ngcc": "ngcc --properties es2015 module main --first-only",
"postinstall": "npm run ngcc"
},
"dependencies": {
"@angular/animations": "~10.1.0",
"@angular/cli": "^10.1.7",
"@angular/common": "~10.1.0",
"@angular/compiler": "~10.1.0",
"@angular/core": "~10.1.0",
"@angular/forms": "~10.1.0",
"@angular/platform-browser": "~10.1.0",
"@angular/platform-browser-dynamic": "~10.1.0",
"@angular/router": "~10.1.0",
"@nativescript/angular": "~10.1.0",
"@nativescript/core": "~7.0.0",
"@nativescript/schematics": "^10.1.0",
"@nativescript/theme": "~2.3.0",
"nativescript-ui-sidedrawer": "^9.0.3",
"nativescript-youtubeplayer": "^3.0.1",
"nativescript-youtubeplayer-inline": "^53.0.1",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.6.0",
"zone.js": "~0.11.1"
},
"devDependencies": {
"@angular/compiler-cli": "~10.1.0",
"@nativescript/android": "7.0.0",
"@nativescript/types": "~7.0.0",
"@nativescript/webpack": "~3.0.0",
"@ngtools/webpack": "~10.1.0",
"typescript": "~3.9.0"
},
"private": "true",
"readme": "NativeScript Application"
}

tsconfig.json:

{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"lib": [
"es2018", "es2017", "dom", "es6"
],
"baseUrl": ".",
"paths": {
"~/": [
"app/"
]
}
},
"include": [
"src/tests//*.ts",
"src//.ios.ts",
"src/**/.android.ts"
],
"files": [
"./references.d.ts",
"./src/main.ts"
],
"exclude": [
"node_modules",
"platforms",
"e2e"
]
}

我尝试将 'target' 设置为 'es5' 仍然面临问题.. 这个 youtube npm 包与这些版本兼容吗? 请让我知道如何解决此问题..

【问题讨论】:

    标签: node.js angular typescript nativescript nativescript-angular


    【解决方案1】:

    这是自 Nativescript 7 for plugins 以来的常见错误。 Nativescript 最近引入了一些重大更改(例如,他们将编译器选项从“ES-5”更改为“ES2017”)。

    插件也必须支持 Nativescript 7。

    这是包含所有说明的 URL:https://nativescript.org/blog/nativescript-7-for-plugin-authors/

    你必须等到 YoutubePlaye 插件支持 Nativescript 7 或者你可以在 YoutubePlaye GitHub 项目中创建一个新问题

    【讨论】:

      【解决方案2】:

      你能试试我的插件https://www.npmjs.com/package/nativescript-youtubeplayer-inline 的分支,添加了对 NS 7 的支持。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-23
      • 1970-01-01
      • 2018-11-12
      • 2019-04-21
      • 2021-05-17
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多