npm3 ❓

npm3 ❓

1d5ca7d8f17f15de4272e1ec7ef7abac?s=128

Daijirō Wachi

August 31, 2015
Tweet

Transcript

  1. ❓ @watilde 2015/08/31 - NodeֶԂ 17࣌ݶ໨

  2. whoami • Daijiro Wachi - @watilde • Front/Back End Engineer

    • interested in npm / V8 / flyjs
  3. beta released at 2015-06-25

  4. Table of contents • Why npm@3? • notes • breaking

    changes • new features • v3.1 - v3.3: Minor updates
  5. Why npm@3? • converting the CLI to an API •

    dependency tree realization • improved support for Windows paths • better error messages & reporting • front-end tooling support • nerf peerDependencies • better CLI search
  6. converting the CLI to an API • ػೳతཁ๬͕ࡍݶͳ͘ಧ͕͘ɺnpm͸طʹߴػೳ • APIͱͯ͠ఏڙͰ͖Ε͹ɺࣗ༝ʹΧελϚΠζՄೳ

    • ͓·͚ʹɺnpmͷίʔυͷςετ͕͠΍͘͢ͳΔ • npm cache & npm-registry-clientͷ࠶ઃܭ • cache.jsͷίʔυ෼཭ɺnpmඇґଘɺmulti-registryαϙʔτ • ΦϑϥΠϯϞʔυͷ࣮૷Λ༰қʹ͢Δ
  7. dependency tree realization • ਖ਼֬ͳΠϯετʔϧͷॱংΛอূ͢Δ
 1. ΠϯετʔϧࡁΈͷpackageΛ֬ೝ
 2. ϩʔΧϧͷnode_modulesͷޮ཰తͳ࠷ऴΠϝʔδߏங
 3.

    ࣮ࡍʹ࣮ߦ͠ͳ͖Ό͍͚ͳ͍ΞΫγϣϯͷϦετߏங
 4. ΠϯετʔϧΛ࣮ߦ • npm i -g npm͕ࣦഊͨ͠ࡍʹࣗ਎͕ফ͑ΔࣄނΛ๷͙ • ؆୯ͦ͏ʹݟ͑ͯɺ࣮ࡍͷϓϩηε͸ඇৗʹෳࡶ
 See also: https://docs.npmjs.com/cli/install#algorithm
  8. improved support for Windows paths • front-endπʔϧͷීٴʹΑΓɺWindowsͰnpm͕α ϙʔτ͖͠Ε͍ͯͳ͍γʔϯ͕සൃ࢝͠Ίͨ • plugin-basedͳπʔϧͷଟ͘͸ɺඇৗʹ௕͍ϑΝΠϧ

    ύεΛཁٻ͢ΔΑ͏ʹͳ͖ͬͯͨ • Windows Ͱ͸ɺ୯Ұύε͸࠷େ 260 จࣈ·Ͱ • npm dedupeͰnode_modulesͷFlatԽΛਪਐ͖ͯͨ͠ ͕ɺ͜ͷ໰୊ͷղܾͷͨΊʹେ୾ʹมߋ͕ඞཁ
  9. better error messages & reporting • ࠷ॳͷࠒͷϢʔβʔͰ͋ΔServer side Node.js Developer͸ɺෳࡶͳUnix

    Error messageΛใࠂ • front-end toolΛ୲͏Α͏ʹͳ͖ͬͯͨͷͰɺ΋ͬͱ ෼͔Γ΍͍͢ΤϥʔΛදࣔͰ͖ΔΑ͏ʹվળ • 1000 issues͕OPENঢ়ଶʹ͋ΓɺreportίϚϯυͷ Α͏ͳܗͰΤϥʔใࠂͷ؆қԽɺ࠷దԽɺޮ཰޲্
  10. front-end tooling support • npmͷར༻ྫͰɺ࠷΋଎͘੒௕͍ͯ͠Δ෼໺ͷ͏ͪͷҰͭ • ଟछଟ༷ͳϢʔεέʔεΛαϙʔτ͢ΔγϯϓϧͳαϒηοτΛ ௐࠪ͢Δ • Ember/Angular/BrowserifyͳͲͷ։ൃνʔϜͱٞ࿦

    • ۩ମతʹෳࡶͳ໰୊͕ൃੜ͍ͯ͠ΔΘ͚Ͱ͸ͳͦ͞͏ͰɺԿ͔໰ ୊͕͋Ε͹ղܾ͢Δͱ͍͏ํ਑ • ecosystemͱ͍͏ɺpluginͷݕࡧΛ༰қʹ͢Δregistryଆͷ৽ػೳ ͳͲ͕༧ఆ͞Ε͍ͯΔ
  11. nerf peerDependencies • require()͢Δpackage͸dependency • testίʔυͷதͰrequire͢Δpackage͸ devDependency • peerDependencies͸ࠞཚͷݪҼʹ •

    See also: https://github.com/npm/npm/issues/5080
  12. better CLI search • ͍·ͷnpm search͸ɺ΋͏গ͠վળͷ༨஍͕͋Δ • npmjs.com Ͱվળ͕׬ྃͨ͠Βɺ
 CLIʹػೳΛ࣋ͬͯ͘Δ

    • Ecosystem, CollectionsͳͲ
  13. notes • npm install -g npm
 npm@3͕betaͳ͏ͪ͸ɺnpm@2ͷ࠷৽͕ೖΔ • npm install

    -g npm@3
 npm@3ͷ࠷৽͕ೖΔ • ҆ఆੑͱޙํޓ׵ͷͳ͍มߋΛίϛϡχςΟʹೝΊ ͯ΋Β͏·Ͱ͸ϕʔλͷ··
  14. • peerDependencies • engineStrict • npm view breaking changes

  15. peerDependencies • Πϯετʔϧ͞Εͳ͘ͳΔ • Πϯετʔϧ͞Ε͍ͯͳ͍ͱɺwarning͕ग़Δ

  16. engineStrict • ͋·Γ࢖ΘΕ͍ͯͳ͔ͬͨ • ܯࠂͷදࣔͷΈͱͳͬͨ • npm config set engine-strict

    trueͰɺengines field ΛݩʹengineStrictͷڍಈΛ࠶ݱՄೳ
  17. npm view • Objectͷ஋͕1ͭͷͱ͖΋ɺArrayΛฦ͢Α͏ʹͳͬ ͨ • e.g.
 Before: versions: '0.0.1'


    After: versions: [ '0.0.1' ]
  18. • Flat, flat, flat! • The multi-stage installer • Install:

    it works different! • Shrinkwraps: they are a-changin'! • The Age of Progress (Bars)! new features
  19. Flat, flat, flat! • node_modulesҎԼ͕ɺՄೳͳݶΓflatʹͳͬͨ • node_modulesҎԼʹɺωετ͞Εͣʹinstall͞Ε Δ • ಉ໊͡લͷҧ͏versionͷdependencyʹґଘͨ͠

    module͕͋Δͱ͖ɺͦΕͧΕͷmoduleͷԼʹωε τ͞Εͯinstall͞ΕΔ
  20. The multi-stage installer • dependency tree realization • read =>

    eval => apply => display • Detail: https://github.com/npm/npm/issues/ 5919#issuecomment-51858095
  21. Install: it works different! • npm ls, npm outdatedʹӨڹ •

    node_modules͕flatʹͳͬͨҰํͰɺtree͸ਖ਼֬ʹ ਌ࢠؔ܎Λදࣔ͢Δ
  22. Shrinkwraps: they are a-changin'! • ॳճͷnpm-shrinkwrap.jsonແ͠ͷinstall
 ೋճ໨ͷnpm-shrinkwrap.json༗ΓͰinstall
 ͜ΕΒ͸ႈ౳Ͱ͋Δ΂͖ • npm-shrinkwrap.json͕͋Δঢ়ଶͰpackage.jsonΛ

    ߋ৽ͨ͠৔߹ɺ൓ө͞ΕΔ΂͖(kinda `—save` opt) • node_modules͕flatʹͳͬͨͷͰɺshrinkwrapʹ΋ ൓ө
  23. The Age of Progress (Bars)! http://blog.npmjs.org/post/110290693555/npm-weekly-4

  24. Flat, flat, flat! http://blog.npmjs.org/post/111968476155/npm-weekly-6

  25. • npm ping • npm install —no-progress • npm team

    • npm access • npm install —only=dev v3.1 - v3.3: Minor updates These features are from v2.13.0 and v2.14.0
  26. npm ping SYNOPSIS npm ping [--registry <registry>]

  27. npm ping • registry͕ਖ਼ৗ͔pingΛ࣮ߦͯ͘͠ΕΔ • API༻్ɺΦϑϥΠϯରԠͷ෍ੴͩͱࢥ͍·͢

  28. npm team SYNOPSIS npm team create <scope:team> npm team destroy

    <scope:team> npm team add <scope:team> <user> npm team rm <scope:team> <user> npm team ls <scope>|<scope:team> npm team edit <scope:team>
  29. npm team • scoped packageΛɺGitHubͷΑ͏ʹorganizer୯Ґ Ͱ؅ཧͰ͖ΔΑ͏ʹͳΔɻΒ͍͠ • Կ౓͔ࢼͨ͠ΜͰ͕͢·ͩಈ͍ͯͳ͍ͷͰௐࠪத

  30. • http://blog.npmjs.org/post/122450408965/npm-weekly-20-npm-3-is-here-ish • http://blog.npmjs.org/post/91303926460/npm-cli-roadmap-a-periodic-update • http://blog.npmjs.org/post/94662089625/the-future-of-the-npm-website-lets-map-this • http://blog.npmjs.org/post/110290693555/npm-weekly-4 • http://blog.npmjs.org/post/111968476155/npm-weekly-6

    • https://github.com/npm/npm/blob/master/CHANGELOG.md • https://github.com/npm/npm/issues/5919#issuecomment-51858095 • https://github.com/npm/npm/issues/5080 • https://twitter.com/othiym23 • http://www.infoq.com/news/2015/06/npm • https://github.com/npm/npm/releases/tag/v2.13.0 • https://github.com/npm/npm/releases/tag/v2.14.0 • http://windows.microsoft.com/ja-jp/windows/file-names-extensions-faq#1TC=windows-7 • https://github.com/npm/npm/search?q=enoent&ref=cmdform&type=Issues Reference links
  31. Happy Hacking!