You can reference the web3.js docs around sending a transaction here:
https://web3js.readthedocs.io/en/v1.2.4/web3-eth.html#sendtransaction
the example looks like:
// using the promise
web3.eth.sendTransaction({
from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
value: '1000000000000000'
})
.then(function(receipt){
...
});
If the from account is not unlocked, you may need to either unlock it or sign the transaction.
Unlocking (results in security concerns)
https://web3js.readthedocs.io/en/v1.2.0/web3-eth-personal.html#unlockaccount
Signing Raw Transaction:
https://web3js.readthedocs.io/en/v1.2.0/web3-eth.html#sendsignedtransaction
Example
Step 1: Start ganache

Step 2: Init NPM project and npm install web3 (version 1.2.4 in this example)
Step 3: Write code (take addresses from ganache available accounts)
var Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
web3.eth.getBalance('0x9e5ef1c0a4b1619be3e83184a6549b5ee11a159c').then(console.log);
// using the promise
web3.eth.sendTransaction({
from: '0x557d3aec51e4461b52c504f087e7122c8906be6c',
to: '0x9e5ef1c0a4b1619be3e83184a6549b5ee11a159c',
value: '10000000'
})
.then(function(receipt){
console.log(receipt.transactionHash);
console.log("ending balance:");
web3.eth.getBalance('0x9e5ef1c0a4b1619be3e83184a6549b5ee11a159c').then(console.log);
});
step 4: run code

(node:7928) UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response:– Ayurpwnz Nov 21 '19 at 21:36Listening on 127.0.0.1:8545and I can not use other code – Ayurpwnz Nov 22 '19 at 10:51ganache-cliyou can use-m "use your own mnemonic just a random set of words"-- this will make it so you can get the same accounts / private keys every time. At this point I'll usually just hardcode the addresses / private keys as configs (this is insecure and just for dev purposes). You can also get accounts programmaticallyweb3.eth.getAccounts().then((accounts) => console.log(accounts[0]));According to this - https://ethereum.stackexchange.com/questions/60995/how-to-get-private-keys-on-truffle-from-ganache-accounts you can get private keys too but never tried – Steven V Nov 24 '19 at 14:26