ngx-translate-extract icon indicating copy to clipboard operation
ngx-translate-extract copied to clipboard

Getting Error while generating extracts- Ng Version -14.0.1

Open rabbi2211 opened this issue 2 years ago • 5 comments

[email protected] 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 avatar Jul 28 '22 10:07 rabbi2211

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

rabbi2211 avatar Jul 28 '22 10:07 rabbi2211

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

[email protected] 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' }

doublemcz avatar Aug 10 '22 08:08 doublemcz

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!

Dylight2810 avatar Aug 17 '22 10:08 Dylight2810

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!)

kapsiR avatar Oct 05 '22 07:10 kapsiR

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

michaelbromley avatar Nov 21 '23 11:11 michaelbromley