Hi @Yong Ding (丁勇) ,
Thanks for reaching out to this forum.
When deploying Function Apps from source control, any package.json file present in your repo, will trigger an npm install in its folder during deployment. But when deploying via the Portal or CLI, you will have to manually install the packages.
Please look into this article which has the ways to install packages in Function app
I hope this answers your question (1).
During the npm install, the dependency package would be pulled from npm public registry. If you are looking use your own modules, this article seems to have the details.
I hope this answers your other queries as well. Feel free to reach out to me if you have any queries.
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.