Closed SamFarrington closed 8 years ago
I may be misunderstanding the use case, but it sounds like you are using shrinkpack inside a library that will be distributed for others to install using npm. Is that the case?
If so, then see https://github.com/JamieMason/shrinkpack/issues/56#issuecomment-231663704 for an explanation of how this is not the intended use case for shrinkpack.
- If you are working on a project which is the root of the tree of dependencies, use shrinkpack.
- If you are working on a project which is itself an npm dependency of other projects, do not use shrinkpack – let downstream projects manage their own bundling.
Shrinkpack is not intended for use in packages published to the registry;
- It's purpose is to add resilience against the registry being unavailable, so to do it within packages which are themselves hosted on that registry would not help.
- The size of packages would grow if 1000s of them all bundled their dependencies, many of which would likely be duplicated.
Please correct me if I misunderstood what it is you're trying to do.
I guess the use case I am encountering is the borderline of your comment above.
The use case is installing a node application on a (production) server with no external network access - i.e. no internet access and no git repo access.
Whilst it may not be the initial intended purpose of this project, this project fits the bill for that purpose pretty well.
The negatives you have mentioned do not apply to this use case as these distributables are used solely as self-contained applications, not provided to any registry to be further developed on/reused by.
That's an interesting use case! And as you say, it's quite different from the "wrapping dependencies of a distributed library" situation.
I've never tried the packed application approach, so I'm probably unable to suggest anything useful.
Just out of curiosity though: are you using bundledDependencies
or the normal dependencies
in your app? I've always thought of bundledDependencies
as being useful when packaging a full application, but maybe that still wouldn't work around the need for shrinkpack
..?
I was going down the route of bundledDependencies before I came across shrinkpack - my (very limited and quite possibly incorrect) understanding of bundledDependencies is that you may hit issues when working cross-platform - i.e. package on windows and deploy on linux as it's the node_modules folder that gets passed about and therefore that may contain platform-specific variations of dependencies.
For the record my current workaround for this issue is to manually archive the application using zip or tar rather than using npm pack
and the unarchiving on the target server and running npm install
in the extracted folder.
This workaround however just feels a little inelegant given the existence of npm pack
Sorry for the delay, I have updated the README to try and better explain how shrinkpack works currently and the kinds of situations it can be used. Please let me know if this does not help and more should be done, thanks.
Steps to Reproduce
Follow the shrinkpack-demo from the main page.
After the last step where the "co-worker" has run npm install, follow these steps in the "co-worker's" directory.
npm pack
This will produce a file called
shrinkpack-demo-1.0.0.tgz
.Move this
shrinkpack-demo-1.0.0.tgz
to a clean directory and then run:npm install shrinkpack-demo-1.0.0.tgz
You will see the following error:
The problem appears to be that it is expecting to find the
node_shrinkwrap
folder in the current directory as in the directory npm is run from. When install a tarball created using npm however the directory that it is installed to will be more likenode_modules/shrinkpack-demo/node_shrinkwrap
Expecting:
./node_shrinkwrap/
Actual:./node_modules/shrinkpack-demo/node_shrinkwrap
Node Version: 4.4.0 NPM Version: 2.14.20
npm-debug.log attached. npm-debug-log.txt