最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Module parse failed: Unexpected token ionic 3 - Stack Overflow

programmeradmin1浏览0评论

After upgrading to the latest module of ionic and ionic-angular am getting this error. Here is my Package.json file after upgrading..

Here is my Package.json file after upgrading..

Runtime Error

Module parse failed: Unexpected token (84:1254) You may need an appropriate loader to handle this file type. | HomelistPage = __decorate([ | Component({ | selector: 'page-homelist',template:/*ion-inline-start:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/`<ion-header>\n <ion-navbar color="bluegray">\n <button ion-button menuToggle color="light">\n <ion-icon name="menu"></ion-icon>\n </button>\n <ion-title color="light">Instractors</ion-title>\n <ion-buttons right>\n <button color="light" ion-button icon-only (click)="createMessage()">\n <ion-icon name="more"></ion-icon>\n </button>\n </ion-buttons>\n </ion-navbar>\n <ion-toolbar color="bluegray">\n <ion-searchbar></ion-searchbar>\n </ion-toolbar>\n</ion-header>\n\n<ion-content>\n <!--*********** 2 colomns list ***********-->\n <ion-grid>\n <ion-row wrap>\n <ion-col tappable col-6 *ngFor="let item of items" (click)="goToDetail(item.$key)" color="gray">\n <ion-card class="cardList">\n <div *ngIf="item.discount" class="ribbon pop-in">SALE</div>\n <img class="pop-in" src={{item.imgSmall}} />\n <ion-card-header>\n {{item.name}}\n </ion-card-header>\n <ion-card-content>\n <p *ngIf="!item.discount" ion-text color="special-blue">\n <strong>${{item.price}}</strong>\n </p>\n <p *ngIf="item.discount" ion-text color="special-blue" class="discount">${{item.price}}</p>\n <p *ngIf="item.discount" ion-text large color="red">\n <strong>${{item.discountPrice}}</strong>\n </p>\n </ion-card-content>\n </ion-card>\n </ion-col>\n </ion-row>\n </ion-grid>\n</ion-content>`/*ion-inline-end:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/, | }), | __metadata("design:paramtypes", [NavController, NavParams, ToastController,


Error: Module parse failed: Unexpected token (84:1254)
You may need an appropriate loader to handle this file type.
|     HomelistPage = __decorate([
|         Component({
|             selector: 'page-homelist',template:/*ion-inline-start:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/`<ion-header>\n  <ion-navbar color="bluegray">\n    <button ion-button menuToggle color="light">\n      <ion-icon name="menu"></ion-icon>\n    </button>\n    <ion-title color="light">Instractors</ion-title>\n        <ion-buttons right>\n          <button color="light" ion-button icon-only (click)="createMessage()">\n            <ion-icon name="more"></ion-icon>\n          </button>\n        </ion-buttons>\n  </ion-navbar>\n  <ion-toolbar color="bluegray">\n    <ion-searchbar></ion-searchbar>\n  </ion-toolbar>\n</ion-header>\n\n<ion-content>\n  <!--*********** 2 colomns list  ***********-->\n  <ion-grid>\n    <ion-row wrap>\n      <ion-col tappable col-6 *ngFor="let item of items" (click)="goToDetail(item.$key)" color="gray">\n        <ion-card class="cardList">\n          <div *ngIf="item.discount" class="ribbon pop-in">SALE</div>\n          <img class="pop-in" src={{item.imgSmall}} />\n          <ion-card-header>\n            {{item.name}}\n          </ion-card-header>\n          <ion-card-content>\n            <p *ngIf="!item.discount" ion-text color="special-blue">\n              <strong>${{item.price}}</strong>\n            </p>\n            <p *ngIf="item.discount" ion-text color="special-blue" class="discount">${{item.price}}</p>\n            <p *ngIf="item.discount" ion-text large color="red">\n              <strong>${{item.discountPrice}}</strong>\n            </p>\n          </ion-card-content>\n        </ion-card>\n      </ion-col>\n    </ion-row>\n  </ion-grid>\n</ion-content>`/*ion-inline-end:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/,
|         }),
|         __metadata("design:paramtypes", [NavController, NavParams, ToastController,
    at Object.448 (http://localhost:8100/build/main.js:1042:7)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.254 (http://localhost:8100/build/main.js:335:68)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.331 (http://localhost:8100/build/main.js:556:96)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.309 (http://localhost:8100/build/main.js:531:70)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at webpackJsonpCallback (http://localhost:8100/build/vendor.js:26:23)
    at http://localhost:8100/build/main.js:1:1

After upgrading to the latest module of ionic and ionic-angular am getting this error. Here is my Package.json file after upgrading..

Here is my Package.json file after upgrading..

Runtime Error

Module parse failed: Unexpected token (84:1254) You may need an appropriate loader to handle this file type. | HomelistPage = __decorate([ | Component({ | selector: 'page-homelist',template:/*ion-inline-start:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/`<ion-header>\n <ion-navbar color="bluegray">\n <button ion-button menuToggle color="light">\n <ion-icon name="menu"></ion-icon>\n </button>\n <ion-title color="light">Instractors</ion-title>\n <ion-buttons right>\n <button color="light" ion-button icon-only (click)="createMessage()">\n <ion-icon name="more"></ion-icon>\n </button>\n </ion-buttons>\n </ion-navbar>\n <ion-toolbar color="bluegray">\n <ion-searchbar></ion-searchbar>\n </ion-toolbar>\n</ion-header>\n\n<ion-content>\n <!--*********** 2 colomns list ***********-->\n <ion-grid>\n <ion-row wrap>\n <ion-col tappable col-6 *ngFor="let item of items" (click)="goToDetail(item.$key)" color="gray">\n <ion-card class="cardList">\n <div *ngIf="item.discount" class="ribbon pop-in">SALE</div>\n <img class="pop-in" src={{item.imgSmall}} />\n <ion-card-header>\n {{item.name}}\n </ion-card-header>\n <ion-card-content>\n <p *ngIf="!item.discount" ion-text color="special-blue">\n <strong>${{item.price}}</strong>\n </p>\n <p *ngIf="item.discount" ion-text color="special-blue" class="discount">${{item.price}}</p>\n <p *ngIf="item.discount" ion-text large color="red">\n <strong>${{item.discountPrice}}</strong>\n </p>\n </ion-card-content>\n </ion-card>\n </ion-col>\n </ion-row>\n </ion-grid>\n</ion-content>`/*ion-inline-end:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/, | }), | __metadata("design:paramtypes", [NavController, NavParams, ToastController,


Error: Module parse failed: Unexpected token (84:1254)
You may need an appropriate loader to handle this file type.
|     HomelistPage = __decorate([
|         Component({
|             selector: 'page-homelist',template:/*ion-inline-start:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/`<ion-header>\n  <ion-navbar color="bluegray">\n    <button ion-button menuToggle color="light">\n      <ion-icon name="menu"></ion-icon>\n    </button>\n    <ion-title color="light">Instractors</ion-title>\n        <ion-buttons right>\n          <button color="light" ion-button icon-only (click)="createMessage()">\n            <ion-icon name="more"></ion-icon>\n          </button>\n        </ion-buttons>\n  </ion-navbar>\n  <ion-toolbar color="bluegray">\n    <ion-searchbar></ion-searchbar>\n  </ion-toolbar>\n</ion-header>\n\n<ion-content>\n  <!--*********** 2 colomns list  ***********-->\n  <ion-grid>\n    <ion-row wrap>\n      <ion-col tappable col-6 *ngFor="let item of items" (click)="goToDetail(item.$key)" color="gray">\n        <ion-card class="cardList">\n          <div *ngIf="item.discount" class="ribbon pop-in">SALE</div>\n          <img class="pop-in" src={{item.imgSmall}} />\n          <ion-card-header>\n            {{item.name}}\n          </ion-card-header>\n          <ion-card-content>\n            <p *ngIf="!item.discount" ion-text color="special-blue">\n              <strong>${{item.price}}</strong>\n            </p>\n            <p *ngIf="item.discount" ion-text color="special-blue" class="discount">${{item.price}}</p>\n            <p *ngIf="item.discount" ion-text large color="red">\n              <strong>${{item.discountPrice}}</strong>\n            </p>\n          </ion-card-content>\n        </ion-card>\n      </ion-col>\n    </ion-row>\n  </ion-grid>\n</ion-content>`/*ion-inline-end:"/Users/macbook/Downloads/studio/src/pages/home/homelist/homelist.html"*/,
|         }),
|         __metadata("design:paramtypes", [NavController, NavParams, ToastController,
    at Object.448 (http://localhost:8100/build/main.js:1042:7)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.254 (http://localhost:8100/build/main.js:335:68)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.331 (http://localhost:8100/build/main.js:556:96)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at Object.309 (http://localhost:8100/build/main.js:531:70)
    at __webpack_require__ (http://localhost:8100/build/vendor.js:55:30)
    at webpackJsonpCallback (http://localhost:8100/build/vendor.js:26:23)
    at http://localhost:8100/build/main.js:1:1
Share Improve this question edited Nov 10, 2017 at 9:15 G B asked Nov 10, 2017 at 9:05 G BG B 2,4533 gold badges21 silver badges33 bronze badges 4
  • can you include your package.json in question? – Suraj Rao Commented Nov 10, 2017 at 9:06
  • @SurajRao updated. – G B Commented Nov 10, 2017 at 9:17
  • There is an open issue github./ionic-team/ionic/issues/13379 – Suraj Rao Commented Nov 10, 2017 at 9:30
  • Just seen it am trying to downgrade it's not working any idea? – G B Commented Nov 10, 2017 at 10:29
Add a ment  | 

2 Answers 2

Reset to default 6

For those experiencing this issue after upgrading to @ionic/app-scripts : 3.1.0 you can fix it by, navigate to node_modules/@ionic/app-scripts/dist/template.js:153 and replace the line of code with this

return getTemplatePrefix(htmlFilePath) + "'" + content + "'" + getTemplateSuffix(htmlFilePath);

This was a manual fix for the bug but as of release. @ionic/app-scripts : 3.1.1 the bug was fixed.

After reading advice from Gerald Brigen and Suraj Rao, I looked at https://github./ionic-team/ionic/issues/13379.

Updated package.json app-scripts from 3.1.0 to 3.1.1. Removed that module and ran npm - i

"devDependencies": {
        "@ionic/app-scripts": "3.1.1",
}
发布评论

评论列表(0)

  1. 暂无评论