3

Suppose I have 2 node packages, one called parent and one called child. child has a package.json with some scripts. Is it possible to include the scripts from child in the context of parent?

For example:

child/package.json:

"scripts":{
   "hello":"echo hello"
}

parent/package.json:

"dependencies":{"child":"1.0.0"}

Then from the command line in the parent directory:

parent> npm run hello //outputs hello

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Ben
  • 16,124
  • 22
  • 77
  • 122

1 Answers1

0

You can run child script from parent but not in parent context.

{scripts: "cd node_modules/child && npm run-script hello"}
ponury-kostek
  • 7,824
  • 4
  • 23
  • 31
  • 2
    yeah but that runs it in the child directory, i want it to execute it in parent... – Ben Feb 17 '17 at 19:54