Js-lingui: how to debug exception in compile process?

Created on 19 Jul 2019  Β·  5Comments  Β·  Source: lingui/js-lingui

There is command line history:

landsman@X230:~/projects/company/web$ npm run extract
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2369/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] extract /home/landsman/projects/company/web
> lingui extract

Catalog statistics:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Language β”‚ Total count β”‚ Missing β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ cs       β”‚     219     β”‚   205   β”‚
β”‚ en       β”‚     215     β”‚   116   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

(use "npm run add-locale <locale>" to add more locales)
(use "npm run extract" to update catalogs with new messages)
(use "npm run compile" to compile catalogs for production)
landsman@X230:~/projects/company/web$ npm run compile
npm WARN lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2369/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> [email protected] compile /home/landsman/projects/company/web
> lingui compile

Compiling message catalogs…
/home/landsman/projects/company/web/node_modules/@lingui/cli/api/catalog.js:131
        return catalogs[locale][key].translation;
                                     ^

TypeError: Cannot read property 'translation' of undefined
    at getTranslation (/home/landsman/projects/company/web/node_modules/@lingui/cli/api/catalog.js:131:38)
    at Object.getTranslation (/home/landsman/projects/company/web/node_modules/@lingui/cli/api/catalog.js:138:27)
    at /home/landsman/projects/company/web/node_modules/@lingui/cli/lingui-compile.js:82:61
    at Array.map (<anonymous>)
    at /home/landsman/projects/company/web/node_modules/@lingui/cli/lingui-compile.js:81:83
    at Array.map (<anonymous>)
    at command (/home/landsman/projects/company/web/node_modules/@lingui/cli/lingui-compile.js:70:18)
    at Object.<anonymous> (/home/landsman/projects/company/web/node_modules/@lingui/cli/lingui-compile.js:142:17)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] compile: `lingui compile`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] compile script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/landsman/.npm/_logs/2019-07-19T14_47_47_850Z-debug.log

And log:

0 info it worked if it ends with ok
1 verbose cli [ '/snap/node/2369/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'compile' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'precompile', 'compile', 'postcompile' ]
5 info lifecycle [email protected]~precompile: [email protected]
6 info lifecycle [email protected]~compile: [email protected]
7 warn lifecycle The node binary used for scripts is /snap/bin/node but npm is using /snap/node/2369/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
8 verbose lifecycle [email protected]~compile: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~compile: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/landsman/projects/company/web/node_modules/.bin:/home/landsman/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
10 verbose lifecycle [email protected]~compile: CWD: /home/landsman/projects/company/web
11 silly lifecycle [email protected]~compile: Args: [ '-c', 'lingui compile' ]
12 silly lifecycle [email protected]~compile: Returned: code: 1  signal: null
13 info lifecycle [email protected]~compile: Failed to exec compile script
14 verbose stack Error: [email protected] compile: `lingui compile`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
14 verbose stack     at EventEmitter.emit (events.js:198:13)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
14 verbose stack     at ChildProcess.emit (events.js:198:13)
14 verbose stack     at maybeClose (internal/child_process.js:982:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
15 verbose pkgid [email protected]
16 verbose cwd /home/landsman/projects/company/web
17 verbose Linux 4.15.0-54-generic
18 verbose argv "/snap/node/2369/bin/node" "/usr/local/bin/npm" "run" "compile"
19 verbose node v10.16.0
20 verbose npm  v6.10.1
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] compile: `lingui compile`
23 error Exit status 1
24 error Failed at the [email protected] compile script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]

There must be a problem with some key in locales file, but I don't know how to degug it.

Implementation is good, it worked before few changes in locale files.

Can you please provide me some steps how to debug this process?
Is there some better way how to find bad row in my locales file?

Thanks

Most helpful comment

So, I debugged that.

There was problem with commented translate which was only in one of two locales.
I probably deleted this obsolete translate from one of locale and forgott it in second one.

Next problem was that this key was translated directly in msgid not in msgstr. Thanks this lingui searched this key in original language - moment of exception.

All 5 comments

So, I debugged that.

There was problem with commented translate which was only in one of two locales.
I probably deleted this obsolete translate from one of locale and forgott it in second one.

Next problem was that this key was translated directly in msgid not in msgstr. Thanks this lingui searched this key in original language - moment of exception.

Problem on screenshot:

image

@tricoder42 Can you please add some helper as I tried here: https://github.com/lingui/js-lingui/pull/545 ? :pray:

@tricoder42 can I help here somehow?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

landsman picture landsman  Β·  4Comments

ccamusso picture ccamusso  Β·  7Comments

benbender picture benbender  Β·  5Comments

MartinCerny-awin picture MartinCerny-awin  Β·  6Comments

LFDMR picture LFDMR  Β·  7Comments