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
Each of those files has a scripts
section in it.
If I go to some_base_folder/projectA/
and run npm run-script test
it executes the test command from the scripts section of some_base_folder/projectA/package.json
as it should.
What can I put as the value of "scripts": {test_projectA:'????'
in some_base_folder/projectB/package.json
so that when I am in some_base_folder/projectB/
and I run npm run-script test_projectA
it will be execute the test
script of Project A?
I tried ../projectA/npm run-script test
but it says:
'..' is not recognized as an internal or external command, operable program or batch file.
I am running under windows 7 but would prefer a solution that would also work properly on linux.
To define an NPM script, set its name and write the script under the 'scripts' property of your package. json file: To execute your Script, use the 'npm run <NAME-OF-YOUR-SCRIPT>' command. Some predefined aliases convert to npm run, like npm test or npm start, you can use them interchangeably.
&& will run your scripts sequentially while & will run them in parallel. A quick way of doing it is npm run start-watch & npm run wp-server . This will run the first command as a background thread. This works really well when one of the commands is not long running and does not need to be manually exited later.
The npm run dev command is a generic npm command that you can find in many modern web application projects. This command is used to run the dev script defined in the project's package. json file. To know what is exactly being run by the command, first you need to open the package.
well it turns out to be quite simple:
"scripts": { test_projectA:"cd ../projectA && npm run-script test" }
You should use --prefix
.
npm run [command] --prefix path/to/your/other/folder
And for yarn:
yarn --cwd path/to/your/other/folder [command]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With