2

We have a package from private npm package store. Now we have source code of it and want to use the source code as local package to test something before pushing to repo in dev machine. How can I achieve it?

Steve Lam
  • 979
  • 1
  • 17
  • 40
  • Possible duplicate of [How to install a private NPM module without my own registry?](https://stackoverflow.com/questions/10386310/how-to-install-a-private-npm-module-without-my-own-registry) – mihai Oct 24 '18 at 13:41
  • It could duplicate but it's other way to resolve the problem, in my case, npm link is good enough – Steve Lam Oct 31 '18 at 02:28

4 Answers4

2

use npm link https://docs.npmjs.com/cli/link

Example from the docs cd ~/projects/node-redis # go into the package directory npm link # creates global link cd ~/projects/node-bloggy # go into some other package directory. npm link redis # link-install the package

Note that package-name is taken from package.json, not from directory name.

Damo
  • 5,698
  • 3
  • 37
  • 55
1

Simply put it in a folder like __server-root/lib/<module-name> and require that folder instead of the npm module.

Enslev
  • 627
  • 3
  • 14
0

following up the answer of Enslev your require could look something like this:

const yourPrivateModule = require('./lib/<module-name>/index.js');
tertek
  • 890
  • 1
  • 10
  • 20
0

npm install /path/to/local/package

This has been answered before

mihai
  • 37,072
  • 9
  • 60
  • 86