Home > Enterprise >  Module parse failed: Unexpected token (7855:112)
Module parse failed: Unexpected token (7855:112)

Time:11-07

I am trying build frontend app using npm run build using jenkins.But getting below error. Could you let me know, how to fix below error?

Creating an optimized production build...
Failed to compile.

./node_modules/xlsx/jszip.js 7855:112
Module parse failed: Unexpected token (7855:112)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|        *     not null.
|        */
>       function gen_bitlen(s, desc) /*    deflate_state *s;*/ /*    tree_desc *desc;    /* the tree descriptor */*/{
|         var tree = desc.dyn_tree;
|         var max_code = desc.max_code;

I am using nodejs version v16.18.1 and npm version 8.19.2..

CodePudding user response:

i am using angular 11 same with you, i think some upgrade packages when install fail

CodePudding user response:

I bumped up the xlsx version from 0.17.5 to the latest one 0.18.5. We use angular 14.1.3. This solved the build issue. But yet to see if that has any side effects on the excel functionality we use in the platform.

CodePudding user response:

After upgrading xlsx version (as @PratikMehta mentioned), if you're dealing with import problems like this in your React project:

Attempted import error: 'xlsx' does not contain a default export (imported as 'XLSX').

Just change the following line

import XLSX from 'xlsx';

to

import * as XLSX from 'xlsx';

Thanks to: https://onlyabug.com/issue/xlsx-is-not-exported-from-xlsx-2632

  • Related