Closed koalabi closed 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)
(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.
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
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.
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 .
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.
Let me know if you have any suggestions or issues or whatnot
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.
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"})
npm audit fix
to fix them, or npm audit
for details
alain@aegnor:/media/elrond_2tb/devel/angular/keyword-tree-ngrx$ ng serve
Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ 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.
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
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
Additional comment: I'm only using the Console appender (no file appender, so far, but I intend to).
Additional comment: I'm only using the Console appender (no file appender, so far, but I intend to).
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$
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';
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
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
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.
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.
WARNING in ./node_modules/@log4js2/core/dist/appender/handler/rolling.file.handler.js.map 1:10 Module parse failed: Unexpected token (1:10) You may need an appropriate loader to handle this file type.
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.