0

I am having an node module which is a CLI script. The CLI uses the process.cwd() to get the current directory from which the cli script is invoked( that is important). This works fine when I install the CLI module globally (https://www.npmjs.com/package/reduxboilergen)

npm i -g <module>

But when I install it locally npm i -S <module> Then 1) The script is not invoked 2) I added a script in package.json and then if I run npm run "script_name", it is invoked but it always takes the directory from where the npm script is invoked as the process.cwd(). So if the folder structure is root - src Then even if I run it inside src directory its picking up root as cwd() as the package.json is in root.

The node_module npm-run ( https://github.com/timoxley/npm-run) solves this problem but is there any other way that you experts can think of so that I dont have to add this dependency?

Sourav Chatterjee
  • 780
  • 2
  • 13
  • 26

1 Answers1

-1

The answer would be npx as of npm 5.2.0

Sourav Chatterjee
  • 780
  • 2
  • 13
  • 26