JS scripting error "undefined has no such function "persist""

That is not the same thing.

The JSScripting add-on comes with a built-in version of the library and it will use that by default. If you want to use a version of the library other than the built-in one (for example that you installed via npm) then you have to go to the add-on settings for JSscripting and explicitly disable the setting that caches the built-in library so that your custom library gets injected into the rule contexts instead.