When trying to use tsc
with my ionic2 project, i am getting the following error on a typescript file.
The Error:
TS2307: Cannot find module 'ionic/ionic'
The Code:
import {Page} from "ionic/ionic" //error happens on this line
@Page({
templateUrl: 'app/list/list.html',
})
export class ListPage {
constructor() {}
}
My tsconfig.json file:
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"sourceMap": true,
"isolatedModules": true,
"noEmitOnError": false,
"rootDir": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"compileOnSave": false
}
My npm -g list:
cordova@5.4.0
ionic@2.0.0-alpha.23
npm@3.4.1
typescript@1.6.2
My Stackoverflow Post
Similar Ionic forum post
Have you tried to update the webpack.config.js?
resolve: {
alias: {
'ionic': 'ionic-framework',
'web-animations.min': 'ionic-framework/js/web-animations.min',
},
extensions: ["", ".js", ".ts"]
}
I had the same issue too. Either you add the ionic alias like the above or you do import {Page} from "ionic-framework/ionic"
UPDATE: see also this
I am also facing same issue,
but following is working fine
import {Page} from 'ionic-framework/ionic';
and below one not.
import {NavController} from 'ionic/ionic'
kuntal
4
if you have latest version ionic cli then you should import from
ionic-angular
2 Likes
I have tried like following and its working fine.
export class Signup{
static get parameters(){
return [[NavController]];
}
constructor(nav){
this.nav=nav;
...
}
}
This is correct, right?