使用camelcase npm 包时出现此错误。
>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
重新安装软件包。
我尝试修改node_module>camlecase>index.js中的包,它工作正常。 错误出现在这一行:
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 不是函数
所以我改变了:
replaceALL() 替换()
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));
这有帮助,程序运行并且错误消失了。