camelcase package give error. TypeError: input.replaceAll is not a function

35 Views Asked by At

am getting this error when am using the camelcase npm package.

>file:///Users/.../using-package-camelcase/node_modules/camelcase/index.js:54
        .replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));   
            ^  
>TypeError: input.replaceAll is not a function 

reinstall the package.

1

There are 1 best solutions below

0
SoUk Aina On

I have tried to modify the package in node_module>camlecase>index.js and it's working fine. the error is found in this line:

    return input
        .replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))
        .replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));

TypeError: input.replaceAll is not a function

so i have change the:

replaceALL() to replace()

    return input
        .replace(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))
        .replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));

this helps, the program runs and the error vanished.