In the following verse James makes it plain that the Christians received life by the word of God and nothing else:
"Of his own will begat he us with the word of truth, that we should be a kind of firstfruits of his creatures" (Jms.1:18).
In the verses of which you speak from the epistle of James the subject is what one person might know about another person's faith:
"Yea, a man may say, Thou hast faith, and I have works: shew me thy faith without thy works, and I will shew thee my faith by my works" (Jms.2:18).
So one man is justified before another man by works and not by faith alone. On the other hand, the Lord knows the heart of man and does not need to see a man's works in order to know whether he has faith or not. I explained the verses to which you brought up from the epistle of James so now address what James said here:
"Of his own will begat he us with the word of truth, that we should be a kind of firstfruits of his creatures" (Jms.1:18).