I want to write a simple way to compress js files, but I have a problem using regularities.
let newStr = str.replace(/(?<!(var|let|const|function))\s/g, "");
the rule is normal in browsers, but an error is reported in node.js
let newStr = str.replace(/(?<!(var|let|const|function))\s/g, "");
^
SyntaxError: Invalid regular expression: /(?<!(var|let|const|function))\s/: Invalid group
at Object.<anonymous> (c:\Users\Administrator\Desktop\test2\test2.js:6:17)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:598:3