I want to launch an npm run
script located in repository A from repository B (both cloned locally).
In repository A the script is defined like this in package.json
:
"scripts": {
"my-script": "node my-script.js"
}
... and it's launched with npm run my-script
. It works fine when launched this way with no errors. The script compiles some files and copies them to different folders inside repo A.
So, my first thought to be able to run that process from repository B was to simply call node my-script.js
from npm.
"scripts": {
"my-script-in-other-repo": "node ../path/to/repo/my-script.js"
}
... and call it with npm run my-script-in-other-repo
in repository B.
Unfortunately this approach throws a bunch of Node and NPM errors which do nothing to help solve this. Stuff like Make sure you have the latest version of node.js and npm installed.
. Here is the output.
My intuition tells me it may be a problem with the Node context, or maybe Node in repository B can't access the dev packages in repository A.
A quick and dirty solution could be to replicate my-script.js
in repository B changing the paths of the files and copying the same dependencies... but it is kinda ugly.
Is there a cleaner way to solve this?