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

Running 'npm pack' after using shrinkpack produces an unusable tarball #69

Closed
SamFarrington opened this issue Aug 16, 2016 · 5 comments
Closed

Comments

@SamFarrington
Copy link

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:

npm install shrinkpack-demo-1.0.0.tgz
npm WARN package.json shrinkpack-demo@1.0.0 No description
npm WARN package.json shrinkpack-demo@1.0.0 No repository field.
npm WARN package.json shrinkpack-demo@1.0.0 No README data
npm ERR! addLocal Could not install C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\nod
e_shrinkwrap\async-2.0.1.tar
npm ERR! addLocal Could not install C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\nod
e_shrinkwrap\commander-2.7.1.tar
npm ERR! addLocal Could not install C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\nod
e_shrinkwrap\express-4.14.0.tar
npm ERR! addLocal Could not install C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\nod
e_shrinkwrap\lodash-4.15.0.tar
npm ERR! addLocal Could not install C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\nod
e_shrinkwrap\request-2.74.0.tar
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\
bin\\npm-cli.js" "install" "shrinkpack-demo-1.0.0.tgz"
npm ERR! node v4.4.0
npm ERR! npm  v2.14.20
npm ERR! path C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\node_shrinkwrap\async-2.0
.1.tar
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open

npm ERR! enoent ENOENT: no such file or directory, open 'C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack
-bug-demo\tarball\node_shrinkwrap\async-2.0.1.tar'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     C:\source\sandbox\shrinkpack-bug-demo\clone\shrinkpack-bug-demo\tarball\npm-debug.log

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 like node_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

@lime
Copy link
Contributor

lime commented Aug 16, 2016

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 #56 (comment) 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.

@SamFarrington
Copy link
Author

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.

@lime
Copy link
Contributor

lime commented Aug 16, 2016

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..?

@SamFarrington
Copy link
Author

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

@JamieMason
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants