log4js2 / log4js2-core

A fast and lightweight logging library that enables logging flexibility within JavaScript/TypeScript applications, similar to Apache's Log4j2
https://log4js2.github.io/log4js2-core
MIT License
10 stars 6 forks source link

Cannot get log4js2 to compile in my application #10

Closed koalabi closed 5 years ago

koalabi commented 5 years ago

Despite to attempts to install log4js2 (the npm site and the project site give 2 slightly different instructions - see below), I cannot get my (otherwise running) application to compile with log4js2.

This is a pity, as the package looks really nice.

First attempt: npm install --save log4js2 Second attempt: npm i -S @log4js2/core

Configuration: node -v: v10.10.0 npm -v: 6.5.0 tsc -v: Version 3.2.2 OS: ubuntu 18.04LTS

Error message: ng serve Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/

Date: 2019-01-05T21:37:01.194Z Hash: 03341d5060cdfc2426d5 Time: 10657ms chunk {main} main.js, main.js.map (main) 105 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 223 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 554 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 6.21 MB [initial] [rendered]

WARNING in ./node_modules/@log4js2/core/dist/appender/handler/file.handler.d.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: /media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@log4js2/core/dist/appender/handler/file.handler.d.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 (/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:719:23) at plugin.done.then (/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@ngtools/webpack/src/loader.js:41:31) at process._tickCallback (internal/process/next_tick.js:68:7)

WARNING in ./node_modules/@log4js2/core/dist/appender/handler/file.writer.d.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: /media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@log4js2/core/dist/appender/handler/file.writer.d.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 (/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:719:23) at plugin.done.then (/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@ngtools/webpack/src/loader.js:41:31) at process._tickCallback (internal/process/next_tick.js:68:7)

WARNING in ./node_modules/@log4js2/core/dist/appender/handler/rolling.file.handler.d.ts Module build failed (from ./node_modules/@ngtools/webpack/src/index.js): Error: /media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@log4js2/core/dist/appender/handler/rolling.file.handler.d.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 (/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:719:23) at plugin.done.then (/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@ngtools/webpack/src/loader.js:41:31) at process._tickCallback (internal/process/next_tick.js:68:7)

WARNING in ./node_modules/@log4js2/core/dist/appender/handler/file.handler.js.map 1:10 Module parse failed: Unexpected token (1:10) You may need an appropriate loader to handle this file type.

{"version":3,"file":"file.handler.js","sourceRoot":"","sources":["../../../src/appender/handler/file.handler.ts"],"names":[],"mappings":";AAA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G,CAAC,GAAG,EAAE;gBACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YAC5B,CAAC,CAAC,CAAC;SACN;aAAM;YACH,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;SAC3B;IAEL,CAAC;CAEJ;AAtDD,kCAsDC"}

WARNING in ./node_modules/@log4js2/core/dist/appender/handler/file.writer.js.map 1:10 Module parse failed: Unexpected token (1:10) You may need an appropriate loader to handle this file type.

{"version":3,"file":"file.writer.js","sourceRoot":"","sources":["../../../src/appender/handler/file.writer.ts"],"names":[],"mappings":";AAAA,MAAM,EAAE,GAAG,IAAI,CAAC;AAChB,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAsB,UAAU;IAKrB,MAAM,CAAC,iBAAiB,CAAC,GAAW;QAEvC,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;QACtC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,MAAM,aAAa,GAAG,GAAG,CAAC;QAE1B,OAAO,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;YAEvD,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;YACrF,IAAI;gBACA,UAAU,CAAC,EAAE,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;aAC7C;YAAC,OAAO,GAAG,EAAE;gBACV,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACvB,OAAO,gBAAgB,CAAC;iBAC3B;gBAED,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACvB,MAAM,IAAI,KAAK,CAAC,qCAAqC,SAAS,GAAG,CAAC,CAAC;iBACtE;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unexpected token (1:10) You may need an appropriate loader to handle this file type.

{"version":3,"file":"rolling.file.handler.js","sourceRoot":"","sources":["../../../src/appender/handler/rolling.file.handler.ts"],"names":[],"mappings":";AAAA,mCAAkC;AAClC,sDAAmD;AAEnD,+CAA2C;AAE3C,MAAa,kBAAmB,SAAQ,wBAAU;IAU9C,YAAoB,OAAmC;QAEnD,KAAK,EAAE,CAAC;QAFQ,YAAO,GAAP,OAAO,CAA4B;QAN/C,aAAQ,GAA2B,EAAE,CAAC;QACtC,WAAM,GAAW,CAAC,CAAC;QACnB,eAAU,GAAY,KAAK,CAAC;QAC5B,WAAM,GAAa,EAAE,CAAC;QACtB,UAAK,GAAW,CAAC,CAAC;QAMtB,MAAM,SAAS,GAAG,wBAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEjE,IAAI,CAAC,wBAAU,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YACtC,wBAAU,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;SAC3C;QAED,IAAI,wBAAU,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACjD,MAAM,KAAK,GAAG,wBAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC5D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;SAC3B;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAErD,IAAI,CAAC,kBAAkB,GAAG,iBAAQ,CAAC,GAAG,EAAE;YACpC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBAClB,IAAI,CAAC,gBAAgB,EAAE,CAAC;aAC3B;QACL,CA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AAC,CAAC;iBAE7D;gBAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAC1D,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YAE5B,CAAC,CAAC,CAAC;SAEN;aAAM;YACH,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;SAC3B;IAEL,CAAC;IAEO,YAAY;QAChB,OAAO,CAAC,CAAC;IACb,CAAC;CAEJ;AAxFD,gDAwFC"}

ERROR in ./node_modules/@log4js2/core/dist/layout/formatter.js Module not found: Error: Can't resolve 'path' in '/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@log4js2/core/dist/layout' ℹ 「wdm」: Failed to compile.

koalabi commented 5 years ago

Additional comment: First compilation failure was less verbose (see below):

ERROR in ./node_modules/log4js2/dist/layout/formatter.js Module not found: Error: Can't resolve 'path' in '/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/log4js2/dist/layout'

Long, verbose diagnostic in original post is related to 2nd attempt (@log4js2/core)

koalabi commented 5 years ago

(Additional question - not related to the problem above) Is there anything to do to get the virtual console effective when using TypeScript? (the mentioned syntax - import from 'log4js2'; or import from '@log4js2/core'; - is rejected by the compiler.

anigenero commented 5 years ago

Make sure you're not using the alpha version of log4js2. There was an erroneous publish that marked the alpha as the most current, and not a "next" release, and I can't retract it. If you're using @log4js2/core, make sure to use 2.0.0-beta.4, as this is the most stable version of the release there is. Let me know if you have any further problems

koalabi commented 5 years ago

Hi Robin,

Thanks for the feedback. It's a bit late for today but I will have a look and let you know.

Kind regards, Alain

On 7/01/19 21:58, Robin Schultz wrote:

Make sure you're not using the alpha version of log4js2. There was an erroneous publish that marked the alpha as the most current, and not a "next" release, and I can't retract it. If you're using @log4js2/core, make sure to use 2.0.0-beta.4, as this is the most stable version of the release there is. Let me know if you have any further problems

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anigenero/log4js2/issues/10#issuecomment-452079379, or mute the thread https://github.com/notifications/unsubscribe-auth/ACqwzSUnLTMuZguuehTM4bsGa0Mpd4TVks5vA7T0gaJpZM4ZyG15.

koalabi commented 5 years ago

Hi Robin,

I have now done a quick check and will explore further. Best news: it's starting to work ;-)).

Not mentioned before, maybe: I'm using TypeScript, not JavaScript. This may explain some points below.

Now for the details:

node example1.js internal/modules/cjs/loader.js:573 throw err; ^

Error: Cannot find module 'core-js/library/fn/object/define' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:571:15) at Function.Module._load (internal/modules/cjs/loader.js:497:25) at Module.require (internal/modules/cjs/loader.js:626:17) at require (internal/modules/cjs/helpers.js:20:18) at Object. (D:\Temp\sqlite-test\node_modules\@log4js2\core\dist\layout\formatter.js:2:16) at Module._compile (internal/modules/cjs/loader.js:678:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10) at Module.load (internal/modules/cjs/loader.js:589:32) at tryModuleLoad (internal/modules/cjs/loader.js:528:12) at Function.Module._load (internal/modules/cjs/loader.js:520:3)

D:\Temp\sqlite-test>npm i core-js --save npm WARN sqlite-test@1.0.0 No description npm WARN sqlite-test@1.0.0 No repository field.

  • core-js@2.6.1 added 1 package in 5.407s

node example1.js

tsc example2.ts && node example2 example2.ts:17:5 - error TS2345: Argument of type '{ layout: string; appenders: string[]; loggers: { tag: string; logLevel: LogLevel; }[]; }' is not assignable to parameter of type 'IConfiguration'. Object literal may only specify known properties, and 'layout' does not exist in type 'IConfiguration'.

17 layout : '%d [%p] %c %M:%line:%column - %m %ex',

Following code compiles OK and runs OK (but lacks the "layout" customization:

configure({ // X layout : '%d [%p] %c %M:%line:%column - %m %ex', appenders : ['Console'], loggers : [{ tag: 'App', / X logLevel/ level : LogLevel.INFO }] });

All in all, that's not bad. I can now continue to further evaluate log4js2 but I have a good feeling ;-) I will keep you informed. Thanks for your support.

On Mon, Jan 7, 2019 at 10:54 PM Alain (Gmail) alain.couniot@gmail.com wrote:

Hi Robin,

Thanks for the feedback. It's a bit late for today but I will have a look and let you know.

Kind regards, Alain On 7/01/19 21:58, Robin Schultz wrote:

Make sure you're not using the alpha version of log4js2. There was an erroneous publish that marked the alpha as the most current, and not a "next" release, and I can't retract it. If you're using @log4js2/core, make sure to use 2.0.0-beta.4, as this is the most stable version of the release there is. Let me know if you have any further problems

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anigenero/log4js2/issues/10#issuecomment-452079379, or mute the thread https://github.com/notifications/unsubscribe-auth/ACqwzSUnLTMuZguuehTM4bsGa0Mpd4TVks5vA7T0gaJpZM4ZyG15 .

anigenero commented 5 years ago

Yeah, the intention was to move repositories for naming sake. I have some loggers I'm creating, and having the same org for all of it makes life more tolerable.

If you use 2.0.0-beta.4 for @log4js2/core, it should fix the issues you're having. Because it's a "next" release, you have to specify it explicitly. I should be publishing the 2.0.0 final release sometime in the next week or two, so it will fix any issues inherit in the default version.

anigenero commented 5 years ago

Let me know if you have any suggestions or issues or whatnot

koalabi commented 5 years ago

Hi Robin, I come back with a mixed bag of outcomes :-(.

First case: a simple GraphQL backend based on graphql-yoga (node application).

SyntaxError: Unexpected string

at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)

Problem is the "import 'reflex-metadata'; (Same experience with node on Windows 7 and a sqlite3 client test and @log4js2/core@2.0.0-beta.4 - Worked OK with -beta.1, provided core-js is also added manually as reported above). Please note I just happen to have tested with brand-new @2.0.3 with the same problem as with @2.0.0-beta.4

Finally, on the same Ubuntu (same machine), for an Angular application, logging works fine with @2.0.0-beta.4 with the core-js dependency (whereas it didn't work for the graphql-yoga backend but the tsconfig.json files are different in the 2 cases (see attached files).

I have now tried different settings and, so far, only those reported to work, have been successful. Any idea? (No hurry, with the "hacks" above, I can proceed ... for the time being).

Thanks for your support and any suggestion. log4js2 does a nice job.

koalabi commented 5 years ago

Forgotten to mention, I'm afraid, for the Angular app to compile, I also had to add "path" as a dependency. This solved the following problem:

$ ng serve Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/

Date: 2019-01-09T17:42:40.307Z Hash: 5c4a78b3e887b9568e30 Time: 17454ms chunk {main} main.js, main.js.map (main) 104 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 223 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 554 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 5.94 MB [initial] [rendered]

ERROR in ./node_modules/@log4js2/core/dist/layout/formatter.js Module not found: Error: Can't resolve 'path' in '/media/elrond_2tb/devel/angular/keyword-tree-ngrx/node_modules/@log4js2/core/dist/layout' ℹ 「wdm」: Failed to compile. ^C alain@aegnor:/media/elrond_2tb/devel/angular/keyword-tree-ngrx$ npm i path --save npm WARN @ngrx/effects@6.1.2 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngrx/router-store@6.1.2 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngrx/router-store@6.1.2 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngrx/router-store@6.1.2 requires a peer of @angular/router@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngrx/store@6.1.2 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself. npm WARN @ngxp/store-service@5.0.1 requires a peer of @angular/common@^6.1.1 but none is installed. You must install peer dependencies yourself. npm WARN @ngxp/store-service@5.0.1 requires a peer of @angular/core@^6.1.1 but none is installed. You must install peer dependencies yourself. npm WARN gulp-typedoc@2.2.1 requires a peer of typedoc@>=0.3.9 but none is installed. You must install peer dependencies yourself. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

Date: 2019-01-09T17:48:25.380Z Hash: ca31525a0b3c31e43567 Time: 11409ms chunk {main} main.js, main.js.map (main) 104 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 223 kB [initial] [rendered] chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered] chunk {styles} styles.js, styles.js.map (styles) 554 kB [initial] [rendered] chunk {vendor} vendor.js, vendor.js.map (vendor) 5.98 MB [initial] [rendered] ℹ 「wdm」: Compiled successfully.

anigenero commented 5 years ago

What version are you using? The error you're experiencing is more than likely from leftover code that included a file appender, which subsequently got removed and placed into its own repo for precisely this reason. I released a stable version yesterday, so make sure @log4js2/core is at version 2.0.3

koalabi commented 5 years ago

Hi Robin, I'm currently running 2.0.0-beta.1 with my Node-based GraphQL backends (no success so far with more recent versions (2.0.0-beta.4 and 2.0.3) as explained above (TypeScript transpilation with libs and target set to "esnext"). For my Angular 6 application, I managed to run 2.0.0-beta.4 but not above. I will now give them a try with @latest (be it 2.0.3 or above and let you know). Thanks, Alain

koalabi commented 5 years ago

Additional comment: I'm only using the Console appender (no file appender, so far, but I intend to).

koalabi commented 5 years ago

Additional comment: I'm only using the Console appender (no file appender, so far, but I intend to).

koalabi commented 5 years ago

I confirm (unfortunately). Trying to use 2.0.4, the transpilation (tsc --lib esnext) succeeds but execution fails:

captions-yoga$ tsc --lib esnext src/index && RXJSSPY_REGEX="^$" DB_CONF_FNAME=ImageChest-PRD-DSB2.json LOG_CONF_FNAME=log4js2-PRD-config.json node src/index /media/elrond_2tb/devel/graphql/captions-yoga/node_modules/@log4js2/core/dist/index.js:1 (function (exports, require, module, filename, dirname) { import 'reflect-metadata'; ^^^^^^^^^^^^^^^^^^

SyntaxError: Unexpected string at new Script (vm.js:79:7) at createScript (vm.js:251:10) at Object.runInThisContext (vm.js:303:10) at Module._compile (internal/modules/cjs/loader.js:657:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18)

You will find my package.json and tsconfig.json files below

tsconfig.json: { "compilerOptions": { / Basic Options / "target": "esnext", / Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. / "module": "commonjs", / Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. / // "lib": [ "esnext", "esnext.asynciterable" ],
// "allowJs": true, / Allow javascript files to be compiled. / // "checkJs": true, / Report errors in .js files. / // "jsx": "preserve", / Specify JSX code generation: 'preserve', 'react-native', or 'react'. / // "declaration": true, / Generates corresponding '.d.ts' file. / // "declarationMap": true, / Generates a sourcemap for each corresponding '.d.ts' file. / // "sourceMap": true, / Generates corresponding '.map' file. / // "outFile": "./", / Concatenate and emit output to single file. / // "outDir": "./", / Redirect output structure to the directory. / // "rootDir": "./", / Specify the root directory of input files. Use to control the output directory structure with --outDir. / // "composite": true, / Enable project compilation / // "removeComments": true, / Do not emit comments to output. / // "noEmit": true, / Do not emit outputs. / // "importHelpers": true, / Import emit helpers from 'tslib'. / // "downlevelIteration": true, / Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. / // "isolatedModules": true, / Transpile each file as a separate module (similar to 'ts.transpileModule'). /

/* Strict Type-Checking Options */
"strict": true,                           /* Enable all strict type-checking options. */
// "noImplicitAny": true,                 /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true,              /* Enable strict null checks. */
// "strictFunctionTypes": true,           /* Enable strict checking of function types. */
// "strictPropertyInitialization": true,  /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true,                /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true,                  /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true,                /* Report errors on unused locals. */
// "noUnusedParameters": true,            /* Report errors on unused parameters. */
// "noImplicitReturns": true,             /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true,    /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
// "moduleResolution": "node",            /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./",                       /* Base directory to resolve non-absolute module names. */
// "paths": {},                           /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [],                        /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [],                       /* List of folders to include type definitions from. */
// 
"types": [
  "node_modules/@types"
],                           /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true,  /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true,              /* Do not resolve the real path of symlinks. */

/* Source Map Options */
// "sourceRoot": "",                      /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "",                         /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true,               /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true,                 /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
// "experimentalDecorators": true,        /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true,         /* Enables experimental support for emitting type metadata for decorators. */

} }

package.json: { "name": "tags-yoga", "version": "1.0.0", "description": "GraphQL server for ImageChest captions (stored in firebirdsql)", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "FirebirdSQL", "tags", "tree" ], "author": "Alain", "license": "ISC", "dependencies": { "keywords": [ "FirebirdSQL", "tags", "tree" ], "author": "Alain", "license": "ISC", "dependencies": { "@log4js2/core": "^2.0.4", "graphql-yoga": "^1.16.7", "node-firebird": "^0.8.6", "rxjs": "^6.3.3", "rxjs-spy": "^7.5.0" }, "devDependencies": {} }

alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ tsc -v Version 3.2.2 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ node -v v10.10.0 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ npm )v bash: syntax error near unexpected token `)' "@log4js2/core": "^2.0.4", "graphql-yoga": "^1.16.7", "node-firebird": "^0.8.6", "rxjs": "^6.3.3", "keywords": [ "FirebirdSQL", "tags", "tree" ], "author": "Alain", "license": "ISC", "dependencies": { "@log4js2/core": "^2.0.4", "graphql-yoga": "^1.16.7", "node-firebird": "^0.8.6", "rxjs": "^6.3.3", "rxjs-spy": "^7.5.0" }, "devDependencies": {} }

alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ tsc -v Version 3.2.2 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ node -v v10.10.0 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ tsc -v Version 3.2.2 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ node -v v10.10.0 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$ npm -v 6.5.0 alain@aegnor:/media/elrond_2tb/devel/graphql/captions-yoga$

koalabi commented 5 years ago

Hi Robin, I have made no progress with 2.0.4 but it's clear the instruction "import 'reflect-metadata';" is what causes the problem. So I tried the following, successively, trying at each stage (but nothing worked):

In all case the error message is 'SyntaxError: Unexpected string" but at runtime; no error at compilation. So, I suspect it has more to do with transpliation settings than with dependencies ...

Now, clearly, the transpiled JavaScript between 2.0.0-beta.1 (that works) and 2.0.4 (that doesn't, here) is visible: 2.0.0-beta.1: function export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } Object.defineProperty(exports, "esModule", { value: true }); require("reflect-metadata");

2.0.4: import 'reflect-metadata'; export * from './log4js';

anigenero commented 5 years ago

I think I've fixed the transpilation issue. I usually have babel in my webpack, so I don't always catch these issues. Version 2.0.5 should fix it

koalabi commented 5 years ago

Hi Robin, Thanks for the feedback. Good news! I have checked with 2 of my projects (one with NodeJS in a server and another one with Angular 6 in the browser). Both compile and seem to run OK. I will further check in the coming days but the issue seems to be solved. A big thanks again for your support. Kind regards