- Metamask is only available as a browser extension and mobile app. Your node js app won't run in the browser environment so it's not possible to connect to your browser metamask app with your node js app. What you can do is export your metamask private key to your environment variable and then use your node js app to send transactions to the blockchain with your metamask account. (I would advise to do so only if you are doing it on testnet, if someone can get access to your private key of mainnet account they can steal all the assets associated with the account)
Here's an example: Send Transaction with node js from your account example
Export private key from metamask: https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-export-an-account-s-private-key
- Check the first link above