This repository has been archived by the owner. It is now read-only.

Ability to install package without its dependencies #340

Closed
arikon opened this Issue Nov 2, 2010 · 12 comments

Comments

Projects
None yet
2 participants
@arikon
Copy link
Contributor

arikon commented Nov 2, 2010

I'm working on npm to debian package converter and I need to install only the package, without its dependencies, during the debian package build process.

@isaacs

This comment has been minimized.

Copy link
Member

isaacs commented Nov 2, 2010

Will #338 address your use case?

@arikon

This comment has been minimized.

Copy link
Contributor Author

arikon commented Nov 3, 2010

Not really. Package is installed using 'npm install .' during debuild process. I think some arg should help here, eg. 'npm install --no-deps .'

@isaacs

This comment has been minimized.

Copy link
Member

isaacs commented Nov 3, 2010

Well, but then you could bundle the dependencies at build-time, so it wouldn't matter.

@arikon

This comment has been minimized.

Copy link
Contributor Author

arikon commented Nov 3, 2010

What do you mean? I didn't get the idea in your comment =(

My case is -- every npm package transforms to single debian package which contains files from only one npm package. All dependencies are transformed as individual debian packages. Thats why I don't want the dependencies being installed during debian package build stage ('npm install .' is run there under the hood).

Take a look at the code to get more information: http://github.com/arikon/npm2debian
Code is generally based on npm code base, all the hard work is done in the lib/source.js

@isaacs

This comment has been minimized.

Copy link
Member

isaacs commented Nov 3, 2010

Ok, so here's what you'd do.

  1. Get the npm package tarball
  2. run npm bundle
  3. now npm install won't try to fetch any dependents, because they're already local.

Also, then you don't have to worry about version conflicts etc., because they'll be statically bundled.

(Note: the functionality doesn't yet exist, I'm just trying to figure out if that would satisfy your use-case.)

@arikon

This comment has been minimized.

Copy link
Contributor Author

arikon commented Nov 5, 2010

Oh, I see now.
This looks like a workaround, but not an ideal solution, because in this particular case I would need to preinstall the npm package or all its dependencies locally before building Debian binary package.

@arikon

This comment has been minimized.

Copy link
Contributor Author

arikon commented Nov 8, 2010

Do you accept this ticket?

@isaacs

This comment has been minimized.

Copy link
Member

isaacs commented Nov 8, 2010

Yes, you would need npm on the build machine, but wouldn't you need that anyway?

I'm not sure it makes sense to have npm install something and not also fetch the dependencies, or build a package without linking the dependencies and ensuring that they are installed.

@arikon

This comment has been minimized.

Copy link
Contributor Author

arikon commented Nov 9, 2010

Preinstalled npm is not the case.

Compare two workflows (with --no-deps feature and without).
With --no-deps:

  1. Run npm2debian source package@ver
  2. Run debuild from debian source tree (it will do npm install --no-deps . which will install only the package, no deps)
    Quite simple.

Without:

  1. Run npm2debian source package@ver
  2. Find some way to preinstall package@ver dependencies locally (npm bundle? npm install? something else?)
  3. Run debuild (it will do npm install . which will find dependencies preinstalled somewhere locally and will install the package only)
@isaacs

This comment has been minimized.

Copy link
Member

isaacs commented Nov 9, 2010

If you aren't going to do dependency resolution at all, or if you're just going to do it using the conflict-inducing debian approach to dependencies, then why not just parse the json and unpack it yourself?

Dependency management is the only hard part, the only core feature that npm actually does, really. While it looks simpler on the surface for your use case, just having this feature will require re-thinking a lot of architectural decisions.

While I'm happy to help develop workarounds to make it easier to install js packages with other package managers, this feature as you've described it is not a good idea for npm.

@isaacs

This comment has been minimized.

Copy link
Member

isaacs commented Nov 9, 2010

As a follow up, these things might be helpful if you want to use npm's internals to write your own script to do some of these things:

  1. the npm cache add <pkg@version> command can fetch and download a package tarball locally to the .npm/.cache dir. It also exposes a utility function, so that you can call cache.add("pkg", "version", function (er, data) { ... }) to fetch package data locally. (This is used almost any time that npm needs to get data from the registry, a folder, or a tarball.)
  2. the npm build command can be used to build an npm package dir and create all the appropriate links and such. It's a plumbing command, and not often used directly, but the syntax would be like this: npm build /path/to/root/.npm/name/version/package. It'll fail if the dependencies are not already installed, but you can do that ahead of time by unpacking the tarballs. It can actually take more than one folder, and from JavaScript, you can also pass it package.json data objects like: npm.commands.build([{package.json data}, ...], cb).
@arikon

This comment has been minimized.

Copy link
Contributor Author

arikon commented Nov 9, 2010

Ok, thanks for info!

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.