mirror of
https://github.com/harish2704/npm-offline-registry.git
synced 2026-09-10 06:21:09 +00:00
Fix:
default Port 8080 is very famous port. So , make some less famous port as default port
This commit is contained in:
@@ -12,10 +12,12 @@ Supper simple NPM registry server for offline NPM install
|
|||||||
*OR*
|
*OR*
|
||||||
`node node_modules/.bin/npm-offline-registry`
|
`node node_modules/.bin/npm-offline-registry`
|
||||||
|
|
||||||
* Now the server will run on [http://localhost:8080](http://localhost:8080)
|
* Now the server will run on [http://localhost:8234](http://localhost:8234)
|
||||||
* use `http://localhost:8080/` as registry while doing npm install
|
* use `http://localhost:8234/` as registry while doing npm install
|
||||||
- Either use `npm install --registry http://localhost:8080/ [package-name]...`
|
- Either use `npm install --registry http://localhost:8234/ [package-name]...`
|
||||||
- Or permanently set config variable `npm config set registry http://localhost:8080/`
|
- Or permanently set config variable `npm config set registry http://localhost:8234/`
|
||||||
|
|
||||||
|
**NOTE:** *default port can be changed by setting `PORT` environment variable *
|
||||||
|
|
||||||
|
|
||||||
# How it is working?
|
# How it is working?
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
|
|
||||||
var app = require('../app');
|
var app = require('../app');
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
|
var config = require( __dirname + '/../config' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get port from environment and store in Express.
|
* Get port from environment and store in Express.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var port = normalizePort(process.env.PORT || '8080');
|
var port = normalizePort( config.PORT );
|
||||||
app.set('port', port);
|
app.set('port', port);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,9 +82,5 @@ function onError(error) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function onListening() {
|
function onListening() {
|
||||||
var addr = server.address();
|
console.log('Listening on http://' + config.LOCAL_REGISTRY );
|
||||||
var bind = typeof addr === 'string'
|
|
||||||
? 'pipe ' + addr
|
|
||||||
: 'port ' + addr.port;
|
|
||||||
console.log('Listening on ' + bind);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
var defaultConfig = {
|
var defaultConfig = {
|
||||||
NPM_PATH : process.env.HOME + '/.npm',
|
NPM_PATH : process.env.HOME + '/.npm',
|
||||||
REGISTRY_NAME : 'registry.npmjs.org',
|
REGISTRY_NAME : 'registry.npmjs.org',
|
||||||
LOCAL_REGISTRY : 'localhost:8080',
|
PORT: 8234
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {};
|
var config = {};
|
||||||
@@ -11,5 +11,7 @@ Object.keys( defaultConfig ).forEach( function(v){
|
|||||||
config[v] = process.env[v] || defaultConfig[v];
|
config[v] = process.env[v] || defaultConfig[v];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
config.LOCAL_REGISTRY = 'localhost:' + config.PORT;
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user