Pro Yearly is on sale from $80 to $50! »

npm v7 Highlights

B1f68959f14f39a7cba2bc9fd4b926e9?s=47 Ruy Adorno
October 27, 2020

npm v7 Highlights

Slides from the talk presented at the GitHub Presente! Online Meetup in Oct 27 2020: https://www.meetup.com/GitHub-Presente/events/273595143/

B1f68959f14f39a7cba2bc9fd4b926e9?s=128

Ruy Adorno

October 27, 2020
Tweet

Transcript

  1. V7 Highlights 27 Oct 2020 • GitHub Presente Meetup @ruyadorno

  2. Ruy Adorno Software Dev npm cli @GitHub

  3. • Make sure to get it • Out with Node.js

    15 • Bugs / Feedback? Reach out:
 github.com/npm/cli
  4. • This presentation takes you through a quick and simple

    demo of a project using npm7 • Let’s go
  5. • npm exec is a new command that brings npx

    to the core cli
  6. • npm exec is a new command that brings npx

    to the core cli • In this example we are going to run an Yeoman Generator by installing both the yo runner and generator-node packages and running as a single command
  7. None
  8. None
  9. None
  10. None
  11. • npm ls now will only show top-level packages by

    default • In order to get the same output as npm6 you can now use the “all” option: npm ls --all
  12. • npm audit got a much more clean and straightforward

    output, it no longer uses tables to display vulnerabilities and vuln count is no longer multiplying every single node in the tree
  13. • Let’s install a version of mkdirp that has a

    known CVE open in the npm security db
  14. • npm install output still let us know about the

    vulnerabilities at the end of an install
  15. None
  16. None
  17. • npm audit fix --force will solve the vulnerability by

    updating to semver-major versions which might in turn contain potential breaking changes
  18. • peerDependencies are now installed by default! Let’s run through

    a quick example by installing a dep that has a peer dep to react and see how it gets installed at the end
  19. None
  20. None
  21. None
  22. None
  23. • workspaces time!

  24. • workspaces time! • In this example we’re going to

    create a sub package (or a workspace) that we’re later on going to define as a workspace in our package.json, get it properly linked on our npm install and then require it from our app
  25. None
  26. None
  27. None
  28. None
  29. • ☝ Workspace created, let’s now add it to the

    workspaces property of the top-level package.json file
  30. None
  31. • All set up! Let’s check everything

  32. None
  33. None
  34. • One of the very nice things about the UX

    around workspaces is the possibility to require that workspace with the same syntax you would use to require a package downloaded from the registry ⬇
  35. None
  36. • This initial workspaces support will help unlock many workflows

    to npm users and there’s much more coming to v7.x with new commands to help working with workspaces. ❤
  37. @ruyadorno

 and remember to: npm install -g npm@7 Thanks!