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

Preserve symlinks on Node.js >=v6.3.0 #244

Closed
zkochan opened this issue Jul 10, 2016 · 1 comment
Closed

Preserve symlinks on Node.js >=v6.3.0 #244

zkochan opened this issue Jul 10, 2016 · 1 comment

Comments

@zkochan
Copy link
Member

zkochan commented Jul 10, 2016

Node.js v6.3.0 introduced a new option --preserve-symlinks that allows to make node resolve dependencies based on the symlinks location, not the realpath (read more: nodejs/node#3402)

This new feature makes it possible to use a global store for pnpm and as a consequence to greatly reduce the disk space needed for dependencies. (a discussion about this was here: #19)

However, the preserve symlinks feature is disabled by default and should be passed to node every time. E.g., node --preserve-symlinks index.js. As a consequence, executable in node_modules/.bin will not be executed with the --preserve-symlinks option.

Proposed changes

(node: I suggest to make these changes on top of #242)

The executables in .bin can be forced to run with --preserve-symlinks by

  1. changing the shebangs to pass the --preserve-symlinks option to node

  2. changing them from symlinks to proxy-files (real files that require the bin files from the symlinked package). E.g.:

    #!/bin/sh
    ":" //# comment; exec /usr/bin/env node --preserve-symlinks "$0" "$@"
    
    require('../eslint/bin/eslint')
  3. making executables from the proxy-files. E.g. chmod 755 node_modules/.bin/eslint

@zkochan zkochan changed the title Preserve symlinks from Node.js v6.3.0 Preserve symlinks on Node.js >=v6.3.0 Jul 10, 2016
@rstacruz
Copy link
Member

Thanks, that's pretty interesting. Just to note, this won't work on all packages; mocha is one example that works a little differently :)

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

2 participants