Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support offline / no-index installs #51

Open
lrowe opened this issue Jan 15, 2016 · 1 comment
Open

Support offline / no-index installs #51

lrowe opened this issue Jan 15, 2016 · 1 comment
Assignees

Comments

@lrowe
Copy link

lrowe commented Jan 15, 2016

We occasionally see build failures due to problems accessing the npm server. While we could run a local npm server instance ourselves, doing so adds unwanted complexity.

The Python world has a simple solution: save a copy of the used packages to a local directory or web accessible directory listing, then install using:

$ pip --no-index --find-links=/path/or/url ...

The package manager will then simply fetch the desired packages from the local directory or from the links extracted from the returned html directory listing. See: https://pip.pypa.io/en/stable/reference/pip_wheel/?highlight=find-links#cmdoption-f

This also provides a simple way to publish private packages within your organisation.

@patrickheeney
Copy link

+1 for this, but its actually a lot more simple. Just need to tie in with npm's cache instead of installing to node_modules/.tmp. When installing a second time, it just checks npm cache for the tarball. This way your compatible with npm, supports offline installs, and really speeds up the install process.

function getUserHome() {
  return process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
}

function getTarball(pkg) {
  return path.join(getUserHome(), '.npm', pkg.name, pkg.version, 'package.tgz');
}

if (pathExists(getTarball(pkg)) {
  // -> alreaded downloaded -> gunzip 
} else {
 // -> download
}

You could later expand this to use a custom path instead of npm's cache, but then it wouldn't work alongside npm.

@alexanderGugel alexanderGugel self-assigned this Feb 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants