There are a few answers to this question.
Firstly, you can just use the install method shown in the npm doc info:
var braintree =require('braintree');
Require might be shown as an error, however it does work.
If you install the npm called dateformat and use the same code:
var dateFormat = require('dateformat');
You won’t get any error message on your preview.
When you get - Uncaught ReferenceError: process is not defined, it means that your Node.js code must be run by the node process, not the browser (the code must run in the server).
If you had access to the code in the actual npm then you could alter the code for it and change it to suit, however as you don’t have access to the code within any npm you can’t do this option.
Also note that the version in Wix Package Manager is only v2.11.0 which is two years out of date and you can see on the Braintree docs that the latest version is now v2.23.0,
Therefore I think that the actual issue here is the npm itself, as if you look on the Braintree docs it states…
The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, Braintree is updating its services to require TLS 1.2 for all HTTPS connections. Braintree will also require HTTP/1.1 for all connections. Please see our technical documentation for more information.
Which means that the version that Wix currently have installed might be one of these versions that are retired from service.
You can read more about it here if you want.
Therefore, all you can do is to go to your installed packages and click on request the latest version to put in a request for Wix to update it to v2.23.0, or at least to a version that is workable in Wix.