The best way to run npm install for nested folders?

前端 未结 9 1880
北恋
北恋 2020-11-30 17:38

What is the most correct way to install npm packages in nested sub folders?

my-app
  /my-sub-module
  package.json
package.json
<
9条回答
  •  时光说笑
    2020-11-30 18:16

    Per @Scott's answer, the install|postinstall script is the simplest way as long as sub-directory names are known. This is how I run it for multiple sub dirs. For example, pretend we have api/, web/ and shared/ sub-projects in a monorepo root:

    // In monorepo root package.json
    {
    ...
     "scripts": {
        "postinstall": "(cd api && npm install); (cd web && npm install); (cd shared && npm install)"
      },
    }
    

提交回复
热议问题