Please read the documentation here and here
var solc = require('solc')
var input = 'contract x { function g() {} }'
// Setting 1 as second parameter activates the optimiser
var optimize = 1
var output = solc.compile(input, optimize)
for (var contractName in output.contracts) {
// code and ABI that are needed by web3
console.log(contractName + ': ' + output.contracts[contractName].bytecode)
console.log(contractName + '; ' + JSON.parse(output.contracts[contractName].interface)
}
you can read the content of the contract from a file also:
var fs = require("fs");
var input = fs.readFileSync('<file path here>', 'utf8');
// rest of the code
If you have any specific question post your code