Should “node_modules” folder be included in the git repository

前端 未结 9 1342
闹比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条回答
  •  -上瘾入骨i
    2020-11-28 03:03

    I would recommend against checking in node_modules because of packages like PhantomJS and node-sass for example, which install the appropriate binary for the current system.

    This means that if one Dev runs npm install on Linux and checks in node_modules – it won't work for another Dev who clones the repo on Windows.

    It's better to check in the tarballs which npm install downloads and point npm-shrinkwrap.json at them. You can automate this process using shrinkpack.

提交回复
热议问题