Alex
Alex

Reputation: 183

Can I install Node.js modules from my own server?

Let's say I have an own server and on the server I have Node.js modules. How can I install these Node modules? Is there global configuration file where I can add my own server? Or can I define my server in an user configuration file in my current Node project? Or is there a parameter like -server which I can add to npm install myownmodule? I want to keep my module private.

Upvotes: 1

Views: 598

Answers (1)

ray
ray

Reputation: 27265

You can point to a tarball url.

Running npm pack will create the tarball, which you can put on your server and then install it via:

npm install <tarball url>

Running your own private npm repo with verdaccio is pretty straightforward too if you'd prefer that route. You can set up .npmrc to publish scoped packages to your own repo instead of npmjs, etc.

Associating a scope with a registry looks like this:

; Set a new registry for a scoped package
@myscope:registry=https://mycustomregistry.example.org

Just replace https://mycustomregistry.example.org with wherever verdaccio is running.

Docs: https://docs.npmjs.com/misc/config#scope

Upvotes: 2

Related Questions