Unable to compile with Angular 5
Closed this issue · 3 comments
Hi,
unfortunately, it's not possible to compile an app with Angular 5 (via angular-cli), including this module.
I get the following error message when I try to compile with 'ng serve':
ERROR in ./node_modules/nl2br-pipe/src/nl2br.pipe.ts
Module build failed: Error: /path/to/project/node_modules/nl2br-pipe/src/nl2br.pipe.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv).
at AngularCompilerPlugin.getCompiledFile (/path/to/project/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:677:23)
at plugin.done.then (/path/to/project/node_modules/@ngtools/webpack/src/loader.js:467:39)
at process._tickCallback (internal/process/next_tick.js:109:7)
You can read about this issue e.g. here: angular/angular-cli#8284
Especially this part gives the hint on the issue: "You have TS files in your node_modules. This really goes against how libraries should be packaged: libraries should never ship their source .ts files."
angular/angular-cli#8284 (comment)
The only (very ugly) way to solve this problem was to add this to the tsconfig.app.json of my app:
"include": [ "../node_modules/nl2br-pipe/**/*.ts", "**/*.ts" ],
Kind regards
Andi
@andi-wr Thank you for the solution but it still does not work. It gives me whole lot of errors. Saying cannot find name 'describe'; cannot find name 'beforeEach' etc in all the files. This is a huge list of errors.
Error output is pretty clear, it needs to be packaged which it isn't. This is right out of the error:
The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format (https://goo.gl/jB3GVv). at AngularCompilerPlugin.getCompiledFile (/Users/aaronosher/Projects/eBallot-App/frontend/node_modules/@ngtools/webpack
Issue is fixed. New version 1.0.1 has been released.
The module is packed as an UMD module which makes it possible to be used within any angular 2+ (including angular 5+) projects.
How to install and to use the module/pipe please check the details here: https://www.npmjs.com/package/nl2br-pipe