gpt4 book ai didi

cordova - Ionic 2 - 'import' 和 'export' 可能仅与 'sourceType: module' 一起出现

转载 作者:太空狗 更新时间:2023-10-29 17:15:41 27 4
gpt4 key购买 nike

使用全新安装的 ionic2 开发新项目,安装 angular2-jwt 后出现此错误:

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

D:\desenv\arquivos\workspace_inbit\medipop-parent\medipop-app\node_modules\angular2-jwt\angular2-jwt.ts:1
import {Injectable, Injector} from 'angular2/core';

重现:

ionic start testapp --v2 --ts 
cd testapp
npm i --save angular2-jwt

和应用页面:

@App({
templateUrl: 'build/app.html',
providers: [
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig({
headerPrefix: '',
noJwtError: true
}), http);
},
deps: [Http]
})
]
})
class MyApp {}

有没有人知道如何解决这个小难题?

最佳答案

尝试将此行添加到您的 ts 配置中:

"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},

如果这不起作用,请尝试在我的计算机上使用此配置(tsconfig.json):

{
"compilerOptions": {
"noImplicitAny": true,
"module": "commonjs",
"target": "ES5",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"declaration": true,
"moduleResolution":"node"
},
"files": [
"angular2-jwt.ts",
"typings/browser.d.ts",
"custom.d.ts"
]
}

关于cordova - Ionic 2 - 'import' 和 'export' 可能仅与 'sourceType: module' 一起出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36438191/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com