flauc / angular2-notifications

A light and easy to use notifications library for Angular.
https://stackblitz.com/edit/angular2-notifications-example
MIT License
746 stars 164 forks source link

Error with Angular 4 ngc compiler #175

Closed jiayihu closed 7 years ago

jiayihu commented 7 years ago

When trying to compile my project which uses this lib with ngc compiler for AOT the following error in thrown:

Error: ENOENT: no such file or directory, open '/Users/jiayi/Desktop/Repo/angular-ui/dist/node_modules/angular2-notifications/src/notification.type.metadata.json'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.writeFileSync (fs.js:1333:33)
    at MetadataWriterHost.writeMetadata (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/@angular/tsc-wrapped/src/compiler_host.js:115:22)
    at MetadataWriterHost._this.writeFile (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/@angular/tsc-wrapped/src/compiler_host.js:92:23)
    at Object.writeFile (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/typescript/lib/typescript.js:64240:132)
    at Object.writeFile (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/typescript/lib/typescript.js:9020:14)
    at printSourceFileOrBundle (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/typescript/lib/typescript.js:61204:16)
    at emitSourceFileOrBundle (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/typescript/lib/typescript.js:61155:21)
    at Object.forEachEmittedFile (/Users/jiayi/Desktop/Repo/angular-ui/node_modules/typescript/lib/typescript.js:8986:17)

I've already checked this errors appears only with Angular 4 migration. If I go back to 2.4.8 everything is fine.

Personally I've seen that notification.type.metadata.json is missing in the package under node_modules, but honestly I can't understand why ngc requires a metadata since it's just an interface without any Angular specific code.

jiayihu commented 7 years ago

Okay I've tried to clone this repo and simply update Angular deps to 4 and compile the lib with tsc:aot and it generates new notification.type.metadata.json indeed. So updating the compiler should fix the issue, although you'll probably need to check if with Angular 2 is still fine hopefully.

flauc commented 7 years ago

Just updated the library to ng4, let me know if you are still getting this error, thanks 👍

jiayihu commented 7 years ago

Works fine thanks!

flauc commented 7 years ago

Thanks for responding so fast 👍

ghost commented 7 years ago

Still facing this problem using ngc. My package.json dependencies are these:

"dependencies": { "@angular/animations": "4.4.0-RC.0", "@angular/common": "4.4.0-RC.0", "@angular/compiler": "4.4.0-RC.0", "@angular/compiler-cli": "4.4.0-RC.0", "@angular/core": "4.4.0-RC.0", "@angular/forms": "4.4.0-RC.0", "@angular/http": "4.4.0-RC.0", "@angular/platform-browser": "4.4.0-RC.0", "@angular/platform-browser-dynamic": "4.4.0-RC.0", "@ionic-native/core": "4.2.1", "@ionic-native/device": "4.2.1", "@ionic-native/push": "4.2.1", "@ionic-native/local-notifications": "4.2.1", "angular2-notifications": "^0.7.7", "angular2-logger": "^0.6.0", "ionic-angular": "3.6.0", "moment": "2.18.1", "rxjs": "5.4.3", "socket.io-client": "2.0.3", "zone.js": "0.8.17" }

Any solution?