Vue component library calls debug-js for node in browser

I have a problem in a vue project I have I´m in the process of breaking out components into a components library.

i get this error message when i consume components from my local components library.

Uncaught TypeError: Cannot read properties of undefined (reading 'fd')
    at Function.useColors 

looking where that is in the code i find this

/**
 * Is stdout a TTY? Colored output is enabled when `true`.
 */

function useColors() {
  return 'colors' in exports.inspectOpts
    ? Boolean(exports.inspectOpts.colors)
    : tty__default["default"].isatty(process.stderr.fd);
}

and a litle googling later it is my understanding is that this code is debug-js for node and that other people have gotten the same error in the past. The solution in the old thread is something with babeland how to resolve modules but i do not seem to be able to find out how to do it for rollup.

Manipulating the bundled code manually so the function returns false makes the code run with no problem but i really do not want to do that

How can I fix this the right way. It seems like I miss something super basic that i for some reason cant find the answer to.

package.json

{
  "name": "local-vue-components",
  "version": "0.1.0",
  "main": "lib/index.js",
  "module": "lib/index.esm.js",
  "scripts": {
    "build": "rollup -c"
  },
  "peerDependencies": {
    "vue": "^2.6.11",
    "vue-class-component": "^7.2.3",
    "vue-property-decorator": "^8.4.2"
  },
  "dependencies": {
    "local-library":"*"
  },
  "devDependencies": {
    "vue": "^2.6.11",
    "vue-class-component": "^7.2.3",
    "vue-property-decorator": "^8.4.2",
    "@rollup/plugin-commonjs": "^14.0.0",
    "@rollup/plugin-node-resolve": "^8.4.0",
    "@rollup/plugin-json":"^5.0.1",
    "@vue/compiler-sfc": "^3.0.0-rc.5",
    "rollup": "^2.23.1",
    "rollup-plugin-peer-deps-external": "^2.2.3",
    "rollup-plugin-typescript2": "^0.27.2",
    "rollup-plugin-vue": "^5.1.6",
    "typescript": "^3.9.7",
    "vue-template-compiler": "^2.6.11"
  }
}

rollup.config.js

import peerDepsExternal from "rollup-plugin-peer-deps-external";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import vue from "rollup-plugin-vue";
import json from "@rollup/plugin-json";

import packageJson from "./package.json";

export default {
  input: "src/index.ts",
  output: [
    {
      format: "cjs",
      file: packageJson.main,
      sourcemap: true
    },
    {
       format: "esm",
       file: packageJson.module,
       sourcemap: true
    }
  ],
  plugins: [peerDepsExternal(), resolve(), commonjs(), typescript(),json(),vue()]
};

I realise it can also be a problem with the consuming project that uses babel and Webpack with the configs below.

babelrc.js

module.exports = function (api) {
    const presets = [
        '@babel/preset-env', 
        {
            targets: {
                chrome: "70"
            }
        }
    ];
    return presets;
}

webpack.js

const path = require("path");

const CopyWebpackPlugin = require('copy-webpack-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

require("@babel/register");

module.exports = {
  entry: {
    babelPollyfill: "@babel/polyfill",
    jprApp: "./src/app/main.ts",
    '
  },
  resolve: {
    extensions: [".js", ".ts", ".json"],
    mainFields: ["browser", "main"],
    alias: {
      vue$: "vue/dist/vue.esm.js"
    }
  },
  module: {
    rules: [
      {
        test: /.(css)$/,
        use: [
        {
          loader: 'file-loader',
          options: {
            name: '[name].css',
          }
        }, {
            loader: 'extract-loader'
        }, {
          loader: 'css-loader',
        }, {
          loader: 'postcss-loader',
        }
      ]
      },
      {
        enforce: "pre",
        use: ["source-map-loader"],
        test: /.js$/
      },
      {
        test: /.ts$/,
        use: 'ts-loader',
        exclude: [/node_modules/,/__test__/]
      },
      {
        test: /.render.js$/,
        use: ["file-loader"]
      },
      {
        test: /.m?js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: "babel-loader",
        }
      }
    ]
  },
  output: {
    publicPath: "",
    filename: "[name].js",
    path: path.resolve(__dirname, "dist")
  },
  plugins: [
  
    new NodePolyfillPlugin(),
    
  ]
};