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
You should use --prefix.
npm run [command] --prefix path/to/your/other/folder
And for yarn:
yarn --cwd path/to/your/other/folder [command]
well it turns out to be quite simple:
"scripts": {
test_projectA:"cd ../projectA && npm run-script test"
}
I ended up using:
"scripts": {
"job": "cd ./sub && \"$npm_execpath\" run subjob",
...
}
because this also works with yarn.