ngx-translate-extract
ngx-translate-extract copied to clipboard
Getting Error while generating extracts- Ng Version -14.0.1
[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.
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
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.
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!
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!)
Maintained fork: https://github.com/vendure-ecommerce/ngx-translate-extract