local npm server or git repo server

59 views
Skip to first unread message

Aaron Gray

unread,
Mar 3, 2015, 11:46:39 AM3/3/15
to nod...@googlegroups.com
Hi,

I have two possible requirements :-

1) A local NPM server that I can run on my Windows machine without
needing to download and store all NPM packages, that will allow me to
override specific packages with my own GitHub packages.

or

2) The ability to refer to either GitHub or local packages or both in
package.json files.

Many thanks in advance,

Aaron

zladuric

unread,
Mar 5, 2015, 9:47:50 AM3/5/15
to nod...@googlegroups.com
You can access your own packages from custom git repos in package.json.

For example, I have:

    "dependencies": {
        "express": : "~4.11.1",
        "my-package": "git+ssh://g...@bitbucket.org:my-org/my-package.git#branch",
        ....
    }

npm install/update will update these each time, I think. You can hit specific branches, tags or refs with #ref part at the end, or just use master.

From then on, use it as normal packages:

    var package = require('my-package');

Zlatko

Jimb Esser

unread,
Mar 5, 2015, 4:17:03 PM3/5/15
to nod...@googlegroups.com
If you use the anonymous URL instead, you won't need ssh keys on the machine to get at it (might be important if you're deploying this somewhere other than your development machine) with something like this in your package.json:
    "my-package": "git://github.com/my-name/my-package.git",

Also, you can use local packages using "npm link" (even for packages which do not exist in npm):
  In the directory of your module you want to use:
    C:\my-package> npm link
  In your app that wants to use it
    C:\my-app> npm link my-package
  This will ignore any version or URL specified in package.json and use your local package instead.

Hope this helps,
  Jimb Esser
Reply all
Reply to author
Forward
0 new messages