Should “node_modules” folder be included in the git repository

前端 未结 9 1379
闹比i
闹比i 2020-11-28 02:41

I\'m wondering if we should be tracking node_modules in our repo or doing an npm install when checking out the code?

9条回答
  •  醉酒成梦
    2020-11-28 03:23

    I would like to offer a middle of the road alternative.

    1. Don't add node_modules into git.
    2. Use a package-lock.json file to nail down your dependency versions.
    3. In your CI or release process, when you release a version make a copy of the node_modules folder and back it up (e.g. in cloud storage).

    In the rare event that you cannot access NPM (or other registries you use) or a specific package in NPM, you have a copy of node_modules and can carry on working until you restore access.

提交回复
热议问题