Working on a new project with a very fresh install of ionic2 ,after install angular2-jwt I am getting this error:
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';
To reproduce:
ionic start testapp --v2 --ts
cd testapp
npm i --save angular2-jwt
and the app page:
@App({
templateUrl: 'build/app.html',
providers: [
provide(AuthHttp, {
useFactory: (http) => {
return new AuthHttp(new AuthConfig({
headerPrefix: '',
noJwtError: true
}), http);
},
deps: [Http]
})
]
})
class MyApp {}
Does anyone have a clue of how to solve this little puzzle?
Try to add this line to your ts
config:
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
If this doesn't work, try with this config wich is working on my computer (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"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With