Open Sathishchary opened 6 years ago
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
@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.
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.
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.
Even I have the same error
Probably related angular issue https://github.com/angular/angular-cli/issues/8284#issuecomment-341417325
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.
"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.
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"
],
@Aitchy13 I tried this. Doesnt work for me.
Worked for me.
Hi, @Aitchy13 workaround worked for me too. Thanks a lot.
Hi, thanks @Aitchy13, you saved me a lot of time !
@Aitchy13 's method is worked for "ng serve" for me ,but not for "ng --prod --aot". so i copy the code into my project
@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
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
Aitchy13 worked for me, your really help me
Same issue here however I'd like to avoid workarounds.
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.
can you please help.