JamieMason / shrinkpack

Fast, resilient, reproducible builds with npm install.
https://www.npmjs.com/package/shrinkpack
MIT License
793 stars 38 forks source link

os.homedir() doesn't seem to be defined #71

Closed dragonsinth closed 8 years ago

dragonsinth commented 8 years ago
> shrinkpack .
! Please raise an issue at https://github.com/JamieMason/shrinkpack/issues

    Error: ! failed to locate the npm cache
        at Object.onError (/usr/local/lib/node_modules/shrinkpack/src/analyse/get-paths.js:26:11)
        at tryCatchReject (/usr/local/lib/node_modules/shrinkpack/node_modules/when/lib/makePromise.js:845:30)
        at runContinuation1 (/usr/local/lib/node_modules/shrinkpack/node_modules/when/lib/makePromise.js:804:4)
        at Rejected.when (/usr/local/lib/node_modules/shrinkpack/node_modules/when/lib/makePromise.js:625:4)
        at Pending.run (/usr/local/lib/node_modules/shrinkpack/node_modules/when/lib/makePromise.js:483:13)
        at Scheduler._drain (/usr/local/lib/node_modules/shrinkpack/node_modules/when/lib/Scheduler.js:62:19)
        at Scheduler.drain (/usr/local/lib/node_modules/shrinkpack/node_modules/when/lib/Scheduler.js:27:9)
        at process._tickCallback (node.js:448:13)
        at Function.Module.runMain (module.js:499:11)
        at startup (node.js:119:16)

I tried to work past this by hard-coding in my ~/.npm cache directory's absolute path here, but I ran into another error immediately after, which is that os.homedir() doesn't seem to be defined. Something is definitely wonky.

Expand to see `npm list -g` ``` /usr/local/lib ├── diff-so-fancy@0.11.1 ├─┬ npm@3.10.6 │ ├── abbrev@1.0.9 │ ├── ansi-regex@2.0.0 │ ├── ansicolors@0.3.2 │ ├── ansistyles@0.1.3 │ ├── aproba@1.0.4 │ ├── archy@1.0.0 │ ├── asap@2.0.4 │ ├── chownr@1.0.1 │ ├── cmd-shim@2.0.2 │ ├─┬ columnify@1.5.4 │ │ └─┬ wcwidth@1.0.0 │ │ └─┬ defaults@1.0.3 │ │ └── clone@1.0.2 │ ├─┬ config-chain@1.1.10 │ │ └── proto-list@1.2.4 │ ├── debuglog@1.0.1 │ ├── dezalgo@1.0.3 │ ├── editor@1.0.0 │ ├── fs-vacuum@1.2.9 │ ├── fs-write-stream-atomic@1.0.8 │ ├── fstream@1.0.10 │ ├─┬ fstream-npm@1.1.0 │ │ └─┬ fstream-ignore@1.0.5 │ │ └─┬ minimatch@3.0.0 │ │ └─┬ brace-expansion@1.1.4 │ │ ├── balanced-match@0.4.1 │ │ └── concat-map@0.0.1 │ ├─┬ glob@7.0.5 │ │ ├── fs.realpath@1.0.0 │ │ ├─┬ minimatch@3.0.2 │ │ │ └─┬ brace-expansion@1.1.5 │ │ │ ├── balanced-match@0.4.1 │ │ │ └── concat-map@0.0.1 │ │ └── path-is-absolute@1.0.0 │ ├── graceful-fs@4.1.4 │ ├── has-unicode@2.0.1 │ ├── hosted-git-info@2.1.5 │ ├── iferr@0.1.5 │ ├── imurmurhash@0.1.4 │ ├── inflight@1.0.5 │ ├── inherits@2.0.1 │ ├── ini@1.3.4 │ ├─┬ init-package-json@1.9.4 │ │ ├─┬ glob@6.0.4 │ │ │ ├─┬ minimatch@3.0.0 │ │ │ │ └─┬ brace-expansion@1.1.4 │ │ │ │ ├── balanced-match@0.4.1 │ │ │ │ └── concat-map@0.0.1 │ │ │ └── path-is-absolute@1.0.0 │ │ └── promzard@0.3.0 │ ├── lockfile@1.0.1 │ ├── lodash._baseindexof@3.1.0 │ ├─┬ lodash._baseuniq@4.6.0 │ │ ├── lodash._createset@4.0.3 │ │ └── lodash._root@3.0.1 │ ├── lodash._bindcallback@3.0.1 │ ├── lodash._cacheindexof@3.0.2 │ ├── lodash._createcache@3.1.2 │ ├── lodash._getnative@3.9.1 │ ├─┬ lodash.clonedeep@4.3.2 │ │ └── lodash._baseclone@4.5.3 │ ├── lodash.restparam@3.6.1 │ ├─┬ lodash.union@4.4.0 │ │ ├── lodash._baseflatten@4.2.1 │ │ └── lodash.rest@4.0.3 │ ├── lodash.uniq@4.3.0 │ ├─┬ lodash.without@4.2.0 │ │ ├─┬ lodash._basedifference@4.5.0 │ │ │ └── lodash._root@3.0.1 │ │ └── lodash.rest@4.0.3 │ ├─┬ mkdirp@0.5.1 │ │ └── minimist@0.0.8 │ ├─┬ node-gyp@3.4.0 │ │ ├─┬ minimatch@3.0.2 │ │ │ └─┬ brace-expansion@1.1.5 │ │ │ ├── balanced-match@0.4.1 │ │ │ └── concat-map@0.0.1 │ │ └─┬ path-array@1.0.1 │ │ └─┬ array-index@1.0.0 │ │ ├─┬ debug@2.2.0 │ │ │ └── ms@0.7.1 │ │ └─┬ es6-symbol@3.1.0 │ │ ├── d@0.1.1 │ │ └─┬ es5-ext@0.10.12 │ │ └── es6-iterator@2.0.0 │ ├── nopt@3.0.6 │ ├── normalize-git-url@3.0.2 │ ├─┬ normalize-package-data@2.3.5 │ │ └─┬ is-builtin-module@1.0.0 │ │ └── builtin-modules@1.1.1 │ ├── npm-cache-filename@1.0.2 │ ├── npm-install-checks@3.0.0 │ ├── npm-package-arg@4.2.0 │ ├─┬ npm-registry-client@7.1.2 │ │ ├─┬ concat-stream@1.5.1 │ │ │ ├─┬ readable-stream@2.0.6 │ │ │ │ ├── core-util-is@1.0.2 │ │ │ │ ├── isarray@1.0.0 │ │ │ │ ├── process-nextick-args@1.0.7 │ │ │ │ ├── string_decoder@0.10.31 │ │ │ │ └── util-deprecate@1.0.2 │ │ │ └── typedarray@0.0.6 │ │ └── retry@0.8.0 │ ├── npm-user-validate@0.1.5 │ ├─┬ npmlog@3.1.2 │ │ ├─┬ are-we-there-yet@1.1.2 │ │ │ └── delegates@1.0.0 │ │ ├── console-control-strings@1.1.0 │ │ ├─┬ gauge@2.6.0 │ │ │ ├── has-color@0.1.7 │ │ │ ├── object-assign@4.1.0 │ │ │ ├── signal-exit@3.0.0 │ │ │ ├─┬ string-width@1.0.1 │ │ │ │ ├─┬ code-point-at@1.0.0 │ │ │ │ │ └── number-is-nan@1.0.0 │ │ │ │ └─┬ is-fullwidth-code-point@1.0.0 │ │ │ │ └── number-is-nan@1.0.0 │ │ │ └── wide-align@1.1.0 │ │ └── set-blocking@2.0.0 │ ├── once@1.3.3 │ ├── opener@1.4.1 │ ├─┬ osenv@0.1.3 │ │ ├── os-homedir@1.0.1 │ │ └── os-tmpdir@1.0.1 │ ├── path-is-inside@1.0.1 │ ├─┬ read@1.0.7 │ │ └── mute-stream@0.0.5 │ ├── read-cmd-shim@1.0.1 │ ├─┬ read-installed@4.0.3 │ │ └── util-extend@1.0.3 │ ├─┬ read-package-json@2.0.4 │ │ ├─┬ glob@6.0.4 │ │ │ ├─┬ minimatch@3.0.0 │ │ │ │ └─┬ brace-expansion@1.1.3 │ │ │ │ ├── balanced-match@0.3.0 │ │ │ │ └── concat-map@0.0.1 │ │ │ └── path-is-absolute@1.0.0 │ │ └─┬ json-parse-helpfulerror@1.0.3 │ │ └── jju@1.3.0 │ ├── read-package-tree@5.1.5 │ ├─┬ readable-stream@2.1.4 │ │ ├── buffer-shims@1.0.0 │ │ ├── core-util-is@1.0.2 │ │ ├── isarray@1.0.0 │ │ ├── process-nextick-args@1.0.7 │ │ ├── string_decoder@0.10.31 │ │ └── util-deprecate@1.0.2 │ ├── readdir-scoped-modules@1.0.2 │ ├── realize-package-specifier@3.0.3 │ ├─┬ request@2.72.0 │ │ ├── aws-sign2@0.6.0 │ │ ├─┬ aws4@1.3.2 │ │ │ └─┬ lru-cache@4.0.1 │ │ │ ├── pseudomap@1.0.2 │ │ │ └── yallist@2.0.0 │ │ ├─┬ bl@1.1.2 │ │ │ └─┬ readable-stream@2.0.6 │ │ │ ├── core-util-is@1.0.2 │ │ │ ├── isarray@1.0.0 │ │ │ ├── process-nextick-args@1.0.6 │ │ │ ├── string_decoder@0.10.31 │ │ │ └── util-deprecate@1.0.2 │ │ ├── caseless@0.11.0 │ │ ├─┬ combined-stream@1.0.5 │ │ │ └── delayed-stream@1.0.0 │ │ ├── extend@3.0.0 │ │ ├── forever-agent@0.6.1 │ │ ├─┬ form-data@1.0.0-rc4 │ │ │ └── async@1.5.2 │ │ ├─┬ har-validator@2.0.6 │ │ │ ├─┬ chalk@1.1.3 │ │ │ │ ├── ansi-styles@2.2.1 │ │ │ │ ├── escape-string-regexp@1.0.5 │ │ │ │ ├── has-ansi@2.0.0 │ │ │ │ └── supports-color@2.0.0 │ │ │ ├─┬ commander@2.9.0 │ │ │ │ └── graceful-readlink@1.0.1 │ │ │ ├─┬ is-my-json-valid@2.13.1 │ │ │ │ ├── generate-function@2.0.0 │ │ │ │ ├─┬ generate-object-property@1.2.0 │ │ │ │ │ └── is-property@1.0.2 │ │ │ │ ├── jsonpointer@2.0.0 │ │ │ │ └── xtend@4.0.1 │ │ │ └─┬ pinkie-promise@2.0.1 │ │ │ └── pinkie@2.0.4 │ │ ├─┬ hawk@3.1.3 │ │ │ ├── boom@2.10.1 │ │ │ ├── cryptiles@2.0.5 │ │ │ ├── hoek@2.16.3 │ │ │ └── sntp@1.0.9 │ │ ├─┬ http-signature@1.1.1 │ │ │ ├── assert-plus@0.2.0 │ │ │ ├─┬ jsprim@1.2.2 │ │ │ │ ├── extsprintf@1.0.2 │ │ │ │ ├── json-schema@0.2.2 │ │ │ │ └── verror@1.3.6 │ │ │ └─┬ sshpk@1.7.4 │ │ │ ├── asn1@0.2.3 │ │ │ ├─┬ dashdash@1.13.0 │ │ │ │ └── assert-plus@1.0.0 │ │ │ ├── ecc-jsbn@0.1.1 │ │ │ ├── jodid25519@1.0.2 │ │ │ ├── jsbn@0.1.0 │ │ │ └── tweetnacl@0.14.3 │ │ ├── is-typedarray@1.0.0 │ │ ├── isstream@0.1.2 │ │ ├── json-stringify-safe@5.0.1 │ │ ├─┬ mime-types@2.1.10 │ │ │ └── mime-db@1.22.0 │ │ ├── node-uuid@1.4.7 │ │ ├── oauth-sign@0.8.1 │ │ ├── qs@6.1.0 │ │ ├── stringstream@0.0.5 │ │ ├── tough-cookie@2.2.2 │ │ └── tunnel-agent@0.4.2 │ ├── retry@0.9.0 │ ├── rimraf@2.5.3 │ ├── semver@5.1.0 │ ├── sha@2.0.1 │ ├── slide@1.1.6 │ ├── sorted-object@2.0.0 │ ├── strip-ansi@3.0.1 │ ├─┬ tar@2.2.1 │ │ └── block-stream@0.0.8 │ ├── text-table@0.2.0 │ ├── uid-number@0.0.6 │ ├── umask@1.1.0 │ ├─┬ unique-filename@1.1.0 │ │ └── unique-slug@2.0.0 │ ├── unpipe@1.0.0 │ ├─┬ validate-npm-package-license@3.0.1 │ │ ├─┬ spdx-correct@1.0.2 │ │ │ └── spdx-license-ids@1.2.0 │ │ └─┬ spdx-expression-parse@1.0.2 │ │ ├── spdx-exceptions@1.0.4 │ │ └── spdx-license-ids@1.2.0 │ ├─┬ validate-npm-package-name@2.2.2 │ │ └── builtins@0.0.7 │ ├─┬ which@1.2.10 │ │ └── isexe@1.1.2 │ ├── wrappy@1.0.2 │ └── write-file-atomic@1.1.4 └─┬ shrinkpack@0.16.3 ├─┬ chalk@1.1.3 │ ├── ansi-styles@2.2.1 │ ├── escape-string-regexp@1.0.5 │ ├─┬ has-ansi@2.0.0 │ │ └── ansi-regex@2.0.0 │ ├── strip-ansi@3.0.1 │ └── supports-color@2.0.0 ├─┬ commander@2.9.0 │ └── graceful-readlink@1.0.1 ├─┬ execa@0.4.0 │ ├─┬ cross-spawn-async@2.2.4 │ │ ├─┬ lru-cache@4.0.1 │ │ │ ├── pseudomap@1.0.2 │ │ │ └── yallist@2.0.0 │ │ └─┬ which@1.2.10 │ │ └── isexe@1.1.2 │ ├── is-stream@1.1.0 │ ├── npm-run-path@1.0.0 │ ├── object-assign@4.1.0 │ ├── path-key@1.0.0 │ └── strip-eof@1.0.0 ├── graceful-fs@4.1.5 ├─┬ gunzip-maybe@1.3.1 │ ├─┬ browserify-zlib@0.1.4 │ │ └── pako@0.2.9 │ ├── is-deflate@1.0.0 │ ├── is-gzip@1.0.0 │ ├─┬ peek-stream@1.1.1 │ │ ├─┬ duplexify@3.4.5 │ │ │ ├── end-of-stream@1.0.0 │ │ │ ├─┬ readable-stream@2.1.5 │ │ │ │ ├── buffer-shims@1.0.0 │ │ │ │ ├── isarray@1.0.0 │ │ │ │ ├── process-nextick-args@1.0.7 │ │ │ │ └── util-deprecate@1.0.2 │ │ │ └── stream-shift@1.0.0 │ │ └─┬ through2@0.5.1 │ │ ├─┬ readable-stream@1.0.34 │ │ │ └── isarray@0.0.1 │ │ └── xtend@3.0.0 │ ├─┬ pumpify@1.3.5 │ │ ├── inherits@2.0.1 │ │ └─┬ pump@1.0.1 │ │ ├── end-of-stream@1.1.0 │ │ └─┬ once@1.3.3 │ │ └── wrappy@1.0.2 │ └─┬ through2@0.4.2 │ ├─┬ readable-stream@1.0.34 │ │ ├── core-util-is@1.0.2 │ │ ├── isarray@0.0.1 │ │ └── string_decoder@0.10.31 │ └─┬ xtend@2.1.2 │ └── object-keys@0.4.0 ├── lodash.assign@4.1.0 └── when@3.7.7 ```

os: OS X Yosemite 10.10.5 node version: v0.10.39 npm@3.10.6 shrinkpack@0.16.3

JamieMason commented 8 years ago

Thanks @dragonsinth, please could you add the following to the original issue?

dragonsinth commented 8 years ago

Done.

Keep in mind that the os.homedir() wasn't the first failure for me. Before that, get-paths.js failed to exec npm config get cache. When I run the command by hand it works just fine.

> npm config get cache
/Users/scottb/.npm
JamieMason commented 8 years ago

Thanks @dragonsinth I will take a look into this soon.

DrewML commented 8 years ago

os.homedir was added in 2.x (source). We may need to pull in a userland lib for that functionality if we want to support node 0.10.x and 0.12.x.

dragonsinth commented 8 years ago

I updated my base node install to 6.5.0 and everything seems good as long as my npm is up to date. Didn't realize I was on an ancient version of node!

JamieMason commented 8 years ago

Thanks all, I've marked node v4 as the minimum version as 0.x support is being phased out in node itself.