vendure-ecommerce / ngx-translate-extract

Extract translatable (using ngx-translate) strings and save as a JSON or Gettext pot file
MIT License
51 stars 19 forks source link

'@angular/compiler' does not provide an export named 'TmplAstForLoopBlock' #28

Closed Val-HeatEng closed 1 year ago

Val-HeatEng commented 1 year ago

Hi, I've followed README instructions to use this tool for my project, getting the following errors. Using Angular16 with TS. Attached package.json and package-lock.json for reference.

package.json package-lock.json

npm run i18n:init

> he-v2-front@0.0.0 i18n:init
> ngx-translate-extract --input ./src --output ./src/assets/i18n/template.json --key-as-default-value --replace --format json

file:///home/vredchenko/dev/he-v2-front/node_modules/@vendure/ngx-translate-extract/dist/parsers/directive.parser.js:1
import { ASTWithSource, Binary, BindingPipe, Conditional, Interpolation, LiteralArray, LiteralMap, LiteralPrimitive, parseTemplate, TmplAstElement as Element, TmplAstTemplate as Template, TmplAstText as Text, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstForLoopBlock, TmplAstDeferredBlock } from '@angular/compiler';
                                                                                                                                                                                                                                                     ^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@angular/compiler' does not provide an export named 'TmplAstForLoopBlock'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)

Node.js v20.9.0
npm run i18n:extract

> he-v2-front@0.0.0 i18n:extract
> ngx-translate-extract --input ./src --output ./src/assets/i18n/{en2,de2}.json --clean --format json

file:///home/vredchenko/dev/he-v2-front/node_modules/@vendure/ngx-translate-extract/dist/parsers/directive.parser.js:1
import { ASTWithSource, Binary, BindingPipe, Conditional, Interpolation, LiteralArray, LiteralMap, LiteralPrimitive, parseTemplate, TmplAstElement as Element, TmplAstTemplate as Template, TmplAstText as Text, TmplAstIfBlock, TmplAstSwitchBlock, TmplAstForLoopBlock, TmplAstDeferredBlock } from '@angular/compiler';
                                                                                                                                                                                                                                                     ^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@angular/compiler' does not provide an export named 'TmplAstForLoopBlock'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)

Node.js v20.9.0
pmpak commented 1 year ago

Hello @Val-HeatEng,

It looks like you installed the fresh release of the library with Angular 17 support :) For Angular 16 you should use the version 8.3.0.

Val-HeatEng commented 1 year ago

Ah thank you for getting back so quickly, that totally solved it. I also reached for a fork that worked: @colsen1991/ngx-translate-extract and that worked out of the box, but I'm guessing this is the primary repo that is best maintained? I can confirm that version 8.3.0 solves the problem, closing issue