How to you reconcile James 2 with salvation apart from works?
First, when you trust in Christ, that is believe the gospel message about the person and work of Christ as God’s Son and His death, resurrection, and ascension as the solution to your sin problem, you are immediately born into the kingdom of God by the Holy Spirit and become a child of God through faith in Christ. This is the very clear message of both John’s gospel and the teaching of Paul in all his epistles.
The book of James does not contradict this when properly understood. James is writing to believers about the need to manifest the reality of their faith in good works, not in order to get saved or stay saved, but (1) to avoid discipline from God and (2) to prove their salvation to the world who cannot see one’s heart. Paul talks about justification by faith before God by the imputation of Christ’s righteousness. This gives one judicial position of justification before God who alone can truly see the heart or the reality of a person’s faith. James is talking about proving our justification in the sight of men. There is clearly no contradiction. Remember that James was present and presiding over the church at Jerusalem when Paul came to help settle the issue of salvation by faith alone in Christ alone (see Acts 15).