npm script command to run a script command from another package.json

后端 未结 3 1059
情书的邮戳
情书的邮戳 2021-02-02 07:20

I have two separate projects that use npm - so I have both :
some_base_folder/projectA/package.json and some_base_folder/projectB/package.json

相关标签:
3条回答
  • 2021-02-02 07:59

    You should use --prefix.

    npm run [command] --prefix path/to/your/other/folder
    

    And for yarn:

    yarn --cwd path/to/your/other/folder [command]
    
    0 讨论(0)
  • 2021-02-02 08:02

    well it turns out to be quite simple:

    "scripts": {
      test_projectA:"cd ../projectA && npm run-script test"
    }
    
    0 讨论(0)
  • 2021-02-02 08:05

    I ended up using:

    "scripts": {
       "job": "cd ./sub && \"$npm_execpath\" run subjob",
       ...
    }
    

    because this also works with yarn.

    0 讨论(0)
提交回复
热议问题