Please don’t forget the first part of this verse…….Submit therefore unto GOD! (See note below)

bible.com/bible/100/jas.4.7.NASB1995

From John MacArthur Study Bible

The only ray of hope in man’s spiritual darkness is the sovereign grace of God, which alone can rescue man from his propensity to lust for evil things. That God gives “greater grace” shows that His grace is greater than the power of sin, the flesh, the world, and Satan (cf. Ro 5:20). The OT quote (from Pr 3:34; cf. 1Pe 5:5) reveals who obtains God’s grace—the humble, not the proud enemies of God.