biesbjerg / ngx-translate-extract

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

Getting Error while generating extracts- Ng Version -14.0.1 #261

Open rabbi2211 opened 1 year ago

rabbi2211 commented 1 year ago

ng-ver@0.0.0 i18n:extract ngx-translate-extract --input ./src --output ./src/assets/i18n/{en,da,de,fi,nb,nl,sv}.json --clean --format json

node:internal/modules/cjs/loader:979 throw new ERR_REQUIRE_ESM(filename, true); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/ravikumar/ng-code/ng-ver/node_modules/@angular/compiler/fesm2015/compiler.mjs not supported. Instead change the require of /Users/ravikumar/ng-code/ng-ver/node_modules/@angular/compiler/fesm2015/compiler.mjs to a dynamic import() which is available in all CommonJS modules. at Object. (/Users/ravikumar/ng-code/ng-ver/node_modules/@biesbjerg/ngx-translate-extract/dist/parsers/pipe.parser.js:3:20) at Object. (/Users/ravikumar/ng-code/ng-ver/node_modules/@biesbjerg/ngx-translate-extract/dist/cli/cli.js:6:23) at Object. (/Users/ravikumar/ng-code/ng-ver/node_modules/@biesbjerg/ngx-translate-extract/bin/cli.js:3:1) {

rabbi2211 commented 1 year ago

Package Version

@angular-devkit/architect 0.1401.0 @angular-devkit/build-angular 14.1.0 @angular-devkit/core 14.1.0 @angular-devkit/schematics 14.1.0 @schematics/angular 14.1.0 rxjs 7.5.6 typescript 4.7.4

doublemcz commented 1 year ago

Hi, I am getting similar error even with Angular 13. After upgrade to Ng 14 it looks a little bit different but with the same source of error. CommonJS vs ES modules.

npm run i18n:extract

timesheets@0.0.0 i18n:extract ngx-translate-extract --input ./src --output ./src/assets/i18n/cs.json --format json --format-indentation " "

node:internal/modules/cjs/loader:979 throw new ERR_REQUIRE_ESM(filename, true); ^

Error [ERR_REQUIRE_ESM]: require() of ES Module \app\node_modules\@angular\compiler\fesm2015\compiler.mjs not supported. Instead change the require of \app\node_modules\@angular\compiler\fesm2015\compiler.mjs to a dynamic import() which is available in all CommonJS modules. at Object. (\app\node_modules\@biesbjerg\ngx-translate-extract\dist\parsers\pipe.parser.js:3:20) at Object. (\app\node_modules\@biesbjerg\ngx-translate-extract\dist\cli\cli.js:6:23) at Object. (\app\webapp\node_modules\@biesbjerg\ngx-translate-extract\bin\cli.js:3:1) { code: 'ERR_REQUIRE_ESM' }

Dylight2810 commented 1 year ago

Hi Kim Biesbjerg & teams , I have the same problem with Angular 14. "@angular-devkit/build-angular": "^14.1.2" "@angular/cli": "^14.1.2" "@angular/compiler-cli": "^14.1.2"

internal/modules/cjs/loader.js:926
throw new ERR_REQUIRE_ESM(filename);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\BMG\accounting-frontend-v2\node_modules\@angular\compiler\fesm2015\compiler.mjs at Module.load (internal/modules/cjs/loader.js:926:11) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) at require (internal/modules/cjs/helpers.js:88:18) at Object. (C:\BMG\accounting-frontend-v2\node_modules\@biesbjerg\ngx-translate-extract\dist\parsers\pipe.parser.js:3:20) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) at Module.load (internal/modules/cjs/loader.js:928:32) at Function.Module._load (internal/modules/cjs/loader.js:769:14) at Module.require (internal/modules/cjs/loader.js:952:19) { code: 'ERR_REQUIRE_ESM' }

Thanks for your help!

kapsiR commented 1 year ago

This is a duplicate of #246, there is an ongoing discussion about forking the project to have it actively maintained again, since @biesbjerg didn't update it for quite some time. (and for the record, it's 💯 his choice to do so!)

michaelbromley commented 8 months ago

Maintained fork: https://github.com/vendure-ecommerce/ngx-translate-extract