connect wix website to a server

UPDATE:
have you tried using es6, import * as net from ‘net’; rather than the require method

I don’t think you can import 3rd party libraries e.g npm packages e.t.c in wix code, my suggestions are

  1. To have a proxy service with a restful api (e.g. microservice implemented using serverless functions) that receives your commands through wix and communicates with your server, you can also have the service respond to your wix code, with status updates via web-hooks in which case you setup your hooks with the WIX HTTP-API/

  2. Have your server communicate directly to Wix as restful API’s, which you implement using the WIX HTTP API