Sunday, 11 June 2017

Install local npm package with custom NODE_PATH

I'm creating a bundle of scripts to run inside a project. I'm following this tutorial here to make the scripts behave as a CLI.

Basically I'm setting the bin property of the pakage.json to be able to install my scripts locally:

```
"bin": {
   "script": "./index.js"
}
```

With this I can run npm install -g inside my project directory and use the scripts as a CLI, cool.

But in this same project I use a custom NODE_PATH to easy the requirements. So I always run it as NODE_PATH=. node index.js.

What is happening is that when I install my project it breaks with a resolveFilename error.

How do I set the NODE_PATH in the npm global installation?



via Pedro Calderon

No comments:

Post a Comment