Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting Error in angular 5.0 #175

Open
Sathishchary opened this issue Nov 8, 2017 · 17 comments
Open

getting Error in angular 5.0 #175

Sathishchary opened this issue Nov 8, 2017 · 17 comments

Comments

@Sathishchary
Copy link

Sathishchary commented Nov 8, 2017

HI, I am converting my angular project form 4.3 to 5.0 ,, I installed the"angular2-logger": "^0.6.0",
but its not working in 5.0
I got below error.

ERROR in ./node_modules/angular2-logger/app/core/level.ts
Module build failed: Error: C:\Users\ksath\Documents\POC\ProjectCli\newProject\node_modules\angular2-logger\app\core\level.t
s is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (C:\Users\ksath\Documents\POC\ProjectCli\newProject\node_modules@ngtools\webpa
ck\src\angular_compiler_plugin.js:624:23)
at plugin.done.then (C:\Users\ksath\Documents\POC\ProjectCli\newProject\node_modules@ngtools\webpack\src\loader.js:467:
39)
@ ./node_modules/angular2-logger/core.js 6:9-36
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

can you please help.

@wojtuch
Copy link

wojtuch commented Nov 9, 2017

Somewhat similar error but on angular 4.4.4.
[edit]: the very same error spotted on logger version 0.5.1.

ERROR in ./node_modules/angular2-logger/app/core/level.ts
Module build failed: Error
    at new FatalError (>>path<<\sources\node_modules\tslint\lib\error.js:31:23)
    at Linter.getSourceFile (>>path<<\sources\node_modules\tslint\lib\linter.js:204:23)
    at Linter.lint (>>path<<\sources\node_modules\tslint\lib\linter.js:72:31)
    at lint (>>path<<\sources\node_modules\tslint-loader\index.js:70:10)
    at Object.module.exports (>>path<<\sources\node_modules\tslint-loader\index.js:140:3)
 @ ./node_modules/angular2-logger/core.js 6:9-36
 @ ./src/app/module.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://docker.for.win.localhost:4200 ./src/main.ts

ERROR in ./node_modules/angular2-logger/app/core/logger.ts
Module build failed: Error
    at new FatalError (>>path<<\sources\node_modules\tslint\lib\error.js:31:23)
    at Linter.getSourceFile (>>path<<\sources\node_modules\tslint\lib\linter.js:204:23)
    at Linter.lint (>>path<<\sources\node_modules\tslint\lib\linter.js:72:31)
    at lint (>>path<<\sources\node_modules\tslint-loader\index.js:70:10)
    at Object.module.exports (>>path<<\sources\node_modules\tslint-loader\index.js:140:3)
 @ ./node_modules/angular2-logger/core.js 7:9-37
 @ ./src/app/module.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://docker.for.win.localhost:4200 ./src/main.ts

ERROR in ./node_modules/angular2-logger/app/core/providers.ts
Module build failed: Error
    at new FatalError (>>path<<\sources\node_modules\tslint\lib\error.js:31:23)
    at Linter.getSourceFile (>>path<<\sources\node_modules\tslint\lib\linter.js:204:23)
    at Linter.lint (>>path<<\sources\node_modules\tslint\lib\linter.js:72:31)
    at lint (>>path<<\sources\node_modules\tslint-loader\index.js:70:10)
    at Object.module.exports (>>path<<\sources\node_modules\tslint-loader\index.js:140:3)
 @ ./node_modules/angular2-logger/core.js 8:9-40
 @ ./src/app/module.ts
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://docker.for.win.localhost:4200 ./src/main.ts

@MitekDev-Mcalvin
Copy link

@Sathishchary I ran into the same problem after upgrading to Angular 5.x. If you go to node_modules\angular2-logger\app\core and remove all of the .ts files in there it will temporarily fix the problem. We need to get a build of this library without the source included in it to fully fix the problem.

@langley-agm
Copy link
Contributor

I'm not going to have time for a while to go into this, but I'll review PRs if receive any. However if angular was what got upgraded and then it started failing, then it sounds to me like an Angular issue.

@MitekDev-Mcalvin
Copy link

MitekDev-Mcalvin commented Nov 10, 2017

I will try and get some time this weekend to help out if I can. It appears that Angular is following Typescripts standards for tsconfig more strictly (blog entry) and there is also more conversation about the problem (as well as some things you can try and do to solve it) here. @langley-agm Thanks for putting this library together, I use it a ton, and am happy to help out if I can.

@appdevchicago
Copy link

Even I have the same error

@abngal
Copy link

abngal commented Nov 28, 2017

Probably related angular issue angular/angular-cli#8284 (comment)

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.

@langley-agm
Copy link
Contributor

langley-agm commented Nov 28, 2017

"This really goes against how libraries should be packaged: libraries should never ship their source .ts files"

I'm not so sure who started stating this crazy idea as a fact, but I'm pretty sure it only started until Typescript started making things harder by not defining standards, not only npm is way newer than other builders to call the shots at what the standard should be but I haven't seen a single source from them stating something like that and many other builders allow you to select whether you want the source included or not, why would this option exist if libraries should never ship their source files?

For reference if you install RxJS you'll see the src files and Angular uses RxJS, or at least they did last time I checked.

Just to clarify, I'm not against removing them, I don't believe that's the correct solution because I've found it incredibly helpful in the past to have the src files in my third party libraries, but I don't mind considering it if its affecting many people. However I do not have the time to research this atm to find a real solution and the fact that they keep changing the structure/standards every couple of months doesn't help. However, like I mentioned before anyone's welcome to publish a PR and I'll take a look at it even if it fixes it by removing the src files.

@Aitchy13
Copy link

As the error states, you need to include a reference to the Typescript files that are imported by angular2-logger so TypeScript is aware of them. Edit the tsconfig.json (or tsconfig.app.json if you're using the angular cli) to include the following snippet:

"include": [
    "../node_modules/angular2-logger/app/core/level.ts",
    "../node_modules/angular2-logger/app/core/logger.ts",
    "../node_modules/angular2-logger/app/core/providers.ts",
    "**/*.ts"
],

@pankajsri03
Copy link

@Aitchy13 I tried this. Doesnt work for me.

@elendil-software
Copy link

Worked for me.

@ricforaf
Copy link

Hi, @Aitchy13 workaround worked for me too. Thanks a lot.

@OlivierCadoz
Copy link

Hi, thanks @Aitchy13, you saved me a lot of time !

@FreezeSoul
Copy link

FreezeSoul commented Jan 31, 2018

@Aitchy13 's method is worked for "ng serve" for me ,but not for "ng --prod --aot". so i copy the code into my project

@Eve-Sama
Copy link

Eve-Sama commented Mar 14, 2018

@FreezeSoul Aitchy13's solution is worked for me,not only 'ng serve',but also 'ng build --prod --aot',maybe cause I add extra solution from stack overflow ,maybe it helps

@pyarun
Copy link

pyarun commented Mar 28, 2018

Solution that worked for me.
the installed package has a dist dir node_modules/angular2-logger/dist/es6/.

in node_modules/angular2-logger/package.json main is set to

"main": "./dist/cjs/core.js",

change this to

"main": "./dist/es6/core.js",

You may have a different dir structure as dist is created during installation process. So the goal shouls be to point main to compiled core.js file.

Change all the import statements for Logger to

import { Logger } from 'angular2-logger';

Compile and run and stay happy.

I don't know wheather this is a typo or delibrate decision, but this works even for ng build --prod

@prudvi
Copy link

prudvi commented May 22, 2018

Aitchy13 worked for me, your really help me

@Hagalas
Copy link

Hagalas commented Jun 20, 2018

Same issue here however I'd like to avoid workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests